Unix/Linux Go Back    


UNIX for Dummies Questions & Answers This forum is closed for new posts. Please post beginner questions to learn unix and learn linux in this forum UNIX for Beginners Questions & Answers

Deleting the unwanted data based on condition

UNIX for Dummies Questions & Answers


 
 
Thread Tools Search this Thread Display Modes
    #1  
Old Unix and Linux 01-26-2013
anurupa777 anurupa777 is offline
Registered User
 
Join Date: Jun 2012
Last Activity: 8 September 2016, 12:17 PM 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 Unix and Linux 01-26-2013
Yoda's Unix or Linux Image
Yoda Yoda is offline Forum Advisor  
Jedi Master
 
Join Date: Jan 2012
Last Activity: 5 December 2016, 4:51 PM EST
Location: Galactic Empire
Posts: 3,529
Thanks: 248
Thanked 1,281 Times in 1,203 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
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux 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 02:33 AM
deleting unwanted files solaris jegaraman Solaris 1 06-07-2011 02:06 AM
Eliminate unwanted data t524ube Shell Programming and Scripting 5 02-17-2009 06:46 PM
OS/X 10.4 Deleting unwanted applications methyl OS X (Apple) 2 01-17-2009 01:35 PM
command for deleting log files based on some condition pulkit Shell Programming and Scripting 4 01-09-2008 06:17 AM



All times are GMT -4. The time now is 05:44 AM.