LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 05-12-2008, 04:55 AM   #1
wood
Member
 
Registered: Aug 2003
Posts: 78

Rep: Reputation: 15
SED @ explanation


I have come across this statement when I am learning the tutorial from this website http://www.magiclinux.org/node/895

#gcc -dumpspecs | sed 's@/lib/ld-linux.so.2@/tools&@g' \
> `dirname $(gcc -print-libgcc-file-name)`/specs

What is the s@/lib/ld-linux.so.2@/tools&@g stands for?
I know that if s/color/colour/g means change all color to colour.
But there is an @ in the statement?

Thank you.
 
Old 05-12-2008, 05:04 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405Reputation: 2405
Hi,

The seperator that is normally used (the /) can be anything you like in sed.

s/xxxx/yyyy/g is the same as s@xxxx@yyyy@g

This way you do not need to escape the slashes in the pathname (/lib/ld-linux instead of \/lib\/ld-linux).

Hope this clears things up a bit.

Last edited by druuna; 05-12-2008 at 05:10 AM. Reason: Fixed a spelling typo
 
Old 05-12-2008, 05:07 AM   #3
pwc101
Senior Member
 
Registered: Oct 2005
Location: UK
Distribution: Slackware
Posts: 1,847

Rep: Reputation: 128Reputation: 128
You can use any delimiter you want in a sed expression; it will use whatever follows the s (in this instance) as the delimiter. So, the following are synonymous:
Code:
sed 's@/lib/ld-linux.so.2@/tools&@g'
sed 's_/lib/ld-linux.so.2_/tools&_g'
sed 's£/lib/ld-linux.so.2£/tools&£g'
They used an @ here because using / would have resulted in a mess:
Code:
sed 's/\/lib\/ld-linux.so.2/\/tools&/g'
edit: Too slow by far!
 
Old 05-13-2008, 06:41 AM   #4
wood
Member
 
Registered: Aug 2003
Posts: 78

Original Poster
Rep: Reputation: 15
Thanks so much for the explanation. Now I am totally clear of it.
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need explanation concerning Beagle. Lola Kews SUSE / openSUSE 7 12-12-2007 08:13 AM
Using "sed" - a simple explanation needed midiox Linux - Newbie 2 04-03-2006 06:47 AM
Explanation of a phenomenon n3tw0rk Linux - Networking 1 11-10-2004 01:21 PM
Insert character into a line with sed? & variables in sed? jago25_98 Programming 5 03-11-2004 06:12 AM
I Could Use An Explanation winger Linux - General 3 04-13-2002 10:32 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration