The UNIX and Linux Forums  

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


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

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Help: for display the 1 column from one file? surainbow Shell Programming and Scripting 5 07-22-2008 02:30 AM
how to grep for a word and display only the word ananthmm UNIX for Dummies Questions & Answers 6 05-29-2008 05:00 AM
print a line containing word in a column using grep useless79 Shell Programming and Scripting 2 11-23-2007 12:32 AM
to display the word containing all of aeiou in a file. arunsubbhian UNIX for Dummies Questions & Answers 1 09-09-2007 12:57 PM
display column in a row vivekshankar UNIX for Dummies Questions & Answers 2 05-23-2005 01:43 PM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 12-24-2007
Registered User
 

Join Date: Nov 2007
Posts: 22
Red face grep a word and display its column

Hi,

I need idea about this, say I have this line:

05 21 * * 0,6 /user/clean.desktop.sh > /tmp/desktop_rpt 2>&1

I would need to grep the word desktop and display the /user/clean.desktop.sh and not the whole line. And if I have some more lines say,

05 21 * * 0,6 /user/clean.desktop.sh > /tmp/desktop_rpt 2>&1
05 21 * * 0,6 /user/clean.laptop.sh || /user/view.desktop.sh > /tmp/view_rpt 2>&1
05 21 * * 0,6 /user/a.sh || /user/desktop.sh > /tmp/view_rpt 2>&1

It will display:
/user/clean.desktop.sh
/user/view.desktop.sh
/user/desktop.sh

Field separator is the white space.

Any idea how?
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 12-24-2007
Moderator
 

Join Date: Dec 2003
Location: /ksh93
Posts: 880
Assuming you are really looking for the string "/user/*desktop.sh", the following sed script
should work

Code:
sed -n 's/.*\(\/user\/.*\/*\.*desktop\.sh\).*$/\1/p' file
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:18 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0