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
Help with AWK -- quick question Probos Shell Programming and Scripting 5 07-18-2007 05:26 PM
quick question keith.m AIX 5 12-21-2006 09:27 AM
quick sed question vbm Shell Programming and Scripting 2 11-09-2006 10:44 PM
quick question pkolishetty UNIX for Dummies Questions & Answers 2 09-02-2006 12:56 PM
Ok quick question Corrail Shell Programming and Scripting 1 11-11-2005 01:49 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-05-2004
hamoudzz hamoudzz is offline
Registered User
  
 

Join Date: Mar 2004
Posts: 4
quick question

hi guys

trying to understand what this line means

sed is a stream editor and i understand that, i have a file already selected
i want to edit so i use -e

sed -e

the next stesp is s/$*

s is a subsititute replacement

sed -e s/$*/[WORDS DELETED]/g

$ is in reference of the last line
/g makes it global so it would search everything

what does */[WORDS DELETED] do?
  #2 (permalink)  
Old 04-06-2004
druuna
Guest
  
 

Posts: n/a
Bits: 0 [Banking]
.....

Last edited by druuna; 05-21-2009 at 10:13 AM..
  #3 (permalink)  
Old 04-06-2004
Perderabo's Avatar
Perderabo Perderabo is online now Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,119
This is an extremely confusing and subtle question. It is very easy to get this wrong.

First the dollar sign works differently in sed depending on where it appears.

sed '$d' < /etc/passwd
will print the contents of /etc/passwd, all except the last line. That is an example of $ being used as a line number.

On the other hand:
echo box | sed 's/.*x$/something/'
echo boxes | sed 's/.*x$/something/'
shows the dollar sign anchoring an expression.

But to act as an anchor, the dollar sign must appear as the last character in the expression. Otherwise it becomes a regular character:
echo '$$$$$$$$' | sed 's/$*/something/'

Now in all of these examples, the sed command was enclosed in single quotes. That is not the case in the question. Thus the shell will see $* and probably replace it. Exactly what will happen depends on the shell and the context. I am using ksh:
set one
echo $*
echo one | sed s/$*/something/

The final command will print "something".
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:35 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