Unix/Linux 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 Linux or Unix Question    
 
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: 3 March 2015, 12:26 AM EST
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: 20 April 2015, 6:16 PM EDT
Location: Galactic Empire
Posts: 3,402
Thanks: 240
Thanked 1,216 Times in 1,142 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 Linux or Unix Question

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Unix or Linux Image 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 11:40 AM.