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
Opinion: Linux Still Doesn't Make It on the Desktop - Computerworld iBot UNIX and Linux RSS News 0 10-01-2007 09:40 AM
Opinion: SCO affair - Time to take stock (and a few shots) - iT News iBot UNIX and Linux RSS News 0 08-18-2007 07:41 PM
Opinion HN19 Post Here to Contact Site Administrators and Moderators 7 12-19-2003 04:00 PM
Your Opinion requested pc9456 SUN Solaris 4 11-17-2003 05:56 AM
Need your help and opinion dennie1 UNIX Desktop for Dummies Questions & Answers 4 07-10-2002 12:19 PM

Reply
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 06-28-2005
Registered User
 

Join Date: Jun 2005
Posts: 19
Stumble this Post!
second opinion on sed script

i'm trying to figure out a script that uses sed, and i'm not totally sure if it does what I think it does.
The script...
- takes in 3 inputs, $1, $2 are names. $3 is a file.
- filename is a file.

Here is what I'm trying to figure out:

cat $3 | grep "id17" > var2
sed "s|@@.*||g" var2 > var3
sed "s/^/filename $1 $2 /g" var3 > $3x
chmod a+x $3x
$3x

so does this mean that...
1. it will cat $3 and then pipe it into grep. Grep will find all the lines that contain id17, and then output it to file var2.
2. sed will substitute all words in var2 that contain @@ in the word. It will do this for the entire line. Then it will output the results to var3.
3. sed will substitute all words in var3 ,that begin with $1 and $2, with the filename. It will do this for the entire line. Then it will output the results to a file that has the same name as file $3, but with an x in it.
4. the file $3x will be chmod to be executable.
5. run file $3x.

thanks,
gammaman
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 06-28-2005
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,443
Stumble this Post!
sed "s/^/filename $1 $2 /g" var3 > $3x

sed will replace the beginning of the line with "filename $1 $2 ". In other words, this gets prepended to the line.
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:19 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