Deleting the unwanted data based on condition | Unix Linux Forums | UNIX for Dummies Questions & Answers

  Go Back    


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 !!

Deleting the unwanted data based on condition

UNIX for Dummies Questions & Answers


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 01-26-2013
anurupa777 anurupa777 is offline
Registered User
 
Join Date: Jun 2012
Last Activity: 13 June 2014, 2:57 AM EDT
Location: INDIA
Posts: 60
Thanks: 14
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
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 29 August 2014, 5:55 PM EDT
Location: Galactic Empire
Posts: 3,362
Thanks: 230
Thanked 1,197 Times in 1,125 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
Closed Thread

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 10:14 AM.