LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 04-03-2006, 05:17 AM   #1
midiox
Member
 
Registered: Oct 2005
Location: Rezekne, Latvia
Distribution: LFS
Posts: 31

Rep: Reputation: 15
Using "sed" - a simple explanation needed


I am a bit new to Linux so am still learning. I am a bit confused. I have some pretty good and new Linux books but cannot find an answer (google gave nothing because it trims out all the special characters from my request):

So I am looking at this command:

Code:
sed -i 's@Sending processes@& started by@g' rc/init.c
and cannot understand why they are using @ sign if every tutorial about sed tells to use "/" ? Can someone explain me what is about that @ and why it is not mentioned in sed usage descriptions?

And the next one:

Code:
sed -e's@#MD5_CRYPT_ENAB.no@MD5_CRYPT_ENAB yes@' \
    -e 's@/var/spool/mail@/var/mail@' \
    etc/login.defs.linux > /etc/login.defs
I copied exactly from the source (LinuxFromScratch book).
Why there is no a whitespace character after the first -e? Is it a mistake? But when I run this command I saw that it still worked fine. What is this all about? And again @ instead of /.

Maybe you could give a link where is something useful about @ charcter with sed?
Thanks for your patience.
 
Old 04-03-2006, 05:59 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728Reputation: 728
Simple explanation?? Hmmmmm---there are whole books written about the nuances of commands like sed.

Here is one good tutorial/reference:
http://www.grymoire.com/Unix/Sed.html#uh-8

The "/" character is the most common delimiter, but any character can be used. Take the simple substitute command (s): The format is s?old?new? where ? is the delimiter. The syntax is simple: The first character after the s becomes the delimiter. The only issue arises if you want to use that same character in another way---then you have to escape it using "\". Thus, if ? is the delimiter, and you wnat to replace "?" with "!", then you would use:
s?\??!?
A bit confusing, n'est-ce pas? Obviously, this is a bit easier to read:
s/?/!/

An old quote about the C language is something about the ability to write totally unintelligible programs. Sed will do that for you also......
 
Old 04-03-2006, 06:47 AM   #3
muha
Member
 
Registered: Nov 2005
Distribution: xubuntu, grml
Posts: 451

Rep: Reputation: 37
Quote:
Originally Posted by midiox
Why there is no a whitespace character after the first -e? Is it a mistake?
Yups, i think it's a typo.

Good sed links:
http://bookmarks.linuxquestions.org/...tries/tags/sed
 
  


Reply

Tags
sed


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Replacing "function(x)" with "x" using sed/awk/smth Griffon26 Linux - General 3 11-22-2006 10:47 AM
[sed] "Advanced" sed question(s) G00fy Programming 2 03-20-2006 12:34 AM
sed of "Solaris 9 Software companion CD" - problem with installation Tinkster Solaris / OpenSolaris 1 12-05-2005 09:35 PM
sed error: "parentheses not balanced" - But they are! Travis86 Programming 2 08-12-2004 07:08 PM
Simple GAIM "ssl support needed" fix Mainframe Slackware 9 05-20-2004 12:51 PM


All times are GMT -5. The time now is 08:09 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration