Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers


UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Reply    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-26-2013
Registered User
 
Join Date: Jun 2012
Location: INDIA
Posts: 52
Thanks: 12
Thanked 1 Time in 1 Post
Deleting the unwanted data based on condition

hi
i have my input data like this

Code:
aaa bbb ccc
asa dff nmj
mnj saa dff
oik
aax cdx saa 
oik
asq sdf dss

i want my output file to be like this

Code:
mnj saa dff  oik
aax cdx saa oik

i want to retain only those lines which will have oik just below them and i want oik to be as next column to those lines in the output file
Sponsored Links
    #2  
Old 01-26-2013
Yoda's Avatar
Jedi Master
 
Join Date: Jan 2012
Location: Galactic Empire
Posts: 2,256
Thanks: 149
Thanked 711 Times in 684 Posts

Code:
awk '$0=="oik"{print p,$0}{p=$0;}' filename

The Following User Says Thank You to Yoda For This Useful Post:
anurupa777 (01-26-2013)
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help with parsing data with awk , eliminating unwanted data rveri Shell Programming and Scripting 5 01-06-2013 01:33 AM
deleting unwanted files solaris jegaraman Solaris 1 06-07-2011 01:06 AM
Eliminate unwanted data t524ube Shell Programming and Scripting 5 02-17-2009 05:46 PM
OS/X 10.4 Deleting unwanted applications methyl OS X (Apple) 2 01-17-2009 12:35 PM
command for deleting log files based on some condition pulkit Shell Programming and Scripting 4 01-09-2008 05:17 AM



All times are GMT -4. The time now is 05:12 PM.