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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SED statement 1

Status
Not open for further replies.
Sep 22, 2004
27
0
0
US
Hi group,

( sed '$d' infile1 ; sed '1d'infile2 ; sed -n '$p'infile2) > outfile.dat

I tried the above script to concatenate 2 files stripping the last line of first file, appending the second file after stripping the first line of second line. In the process as the last line of the second file was also stripped off which was kind of strange and undesirable, i am forcing the last line of the second file into the output file. however, im not getting the desired result.
Please help in editing the above code.
Thanks
Roe.
 
[tt]
awk '
NR>1&&(NR==FNR||FNR>2){print s}
{s=$0}
END{print s}' file1 file2
[/tt]
 
(sed '$d' infile1; tail +2l infile2) > outfile.dat

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

Part and Inventory Search

Sponsor

Back
Top