Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delete lines

Status
Not open for further replies.

ecmanfr

Technical User
Joined
May 14, 2005
Messages
9
Location
FR
Hello,

In a file I would like delete the last 2 lines, and the other file I would like delete the 2 first lines and concat the 2 files

Thank You.
 
In an unix shell:
(sed '$d' /path/to/input1 | sed '$d'; sed '1,2$' /path/to/input2) >/path/to/output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry,

I work with awk95 under win32

I don't know the sed command
 
(sed 'N;$!P;$!D;$d' /path/to/input1; sed '1,2d' /path/to/input2) > >/path/to/output

sed1liners

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
ecmanfr.awk:
NR==FNR{a[++i]=$0;next}
FNR==3{for(j=1;j<i-1;++j)print a[j]}
{print}

awk95 -f ecmanfr.awk file1 file2 > output

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top