The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

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

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-28-2005
gammaman gammaman is offline
Registered User
  
 

Join Date: Jun 2005
Posts: 19
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
  #2 (permalink)  
Old 06-28-2005
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,111
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.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 02:22 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0