Register
It is currently Sat Sep 20, 2014 9:59 am

help with exam


All times are UTC - 6 hours


Post new topic Reply to topic  [ 3 posts ] 
Author Message
 PostPosted: Tue Mar 01, 2011 5:31 am   

Joined: Tue Mar 01, 2011 5:25 am
Posts: 2
Hi everybody,
I need help. For an exam, I should need to answer these question:

"What will the following sed script do when applied to the file passed as an argument? WHY?

sed '
/^\/\*/d
/.*\*\//d
' $1

"

The sed command is written as I will find it in the exam, so it is not
sed '/^\/...... on the same line but it is exactly as you see it here:

sed ' then on a new line /^\/\*/d then on a new line /.*\*\//d then on a new line ' $1

Please help me because I have absolutely no idea!!!


Top
 Profile  
 PostPosted: Fri Mar 25, 2011 12:07 pm   
User avatar

Joined: Tue Apr 27, 2010 2:28 pm
Posts: 172
Location: Czech Republic
Sed script can contain newlines between commands. It is essentially the same as
Code:
sed '/^\/\*/d;/.*\*\//d' $1
but more readable :-B


Top
 Profile  
 PostPosted: Tue May 03, 2011 10:49 am   
Site Admin
User avatar

Joined: Sun May 15, 2005 9:36 pm
Posts: 667
Location: Des Moines, Iowa
he he he, like sed is readable whatever way you type it lol :)

Sometimes just comparing code can be helpful in deciphering the sed script.
http://sed.sourceforge.net/sed1line.txt has always been useful for me.

That and I have the second edition of "Sed and Awk" from O'Reilly books, another great reference.


Top
 Profile WWW  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP