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

text file task

Status
Not open for further replies.

ogniemi

Technical User
Nov 7, 2003
1,041
PL
Hello,
I've a text file with similiar contents:

1
abc
2
abc
3
def
4
abc
5
def
6
abc
7
abc

Questions:
1. How to join each 2 lines (starting from top of hte file) to one line
2. How to print line containing def and one line before each of this line

I have no gnu grep in my system.


regards,
m.

 
Try

1. paste -s -d" \n" file
2. paste -s -d" \n" file | grep def
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top