LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Sed - command (https://www.linuxquestions.org/questions/linux-newbie-8/sed-command-4175564054/)

Saro 01-15-2016 04:06 PM

Sed - command
 
Hello all,

I'm glad to be part of this community. I'm totally new to Linux, starting with Linux+ and lets see, but I'm not new in IT, infact over 8 years of Network engineering experience.

if anyone could be so kind and explain the following command, i know what it does, but i don't get 's/ and /g part.

sed 's/bob/Bobs/g' letter > anotherletter

thanks

JockVSJock 01-15-2016 04:16 PM

Quote:

Originally Posted by Saro (Post 5478881)
if anyone could be so kind and explain the following command, i know what it does, but i don't get 's/ and /g part.

sed 's/bob/Bobs/g' letter > anotherletter

thanks


the "s" tells Sed to execute the substitute command

bob is the original string

Bobs is the replacement string

the "g" is global flag which it will replace all and any bob to Bobs

Looks like the change is happening to a file called letter. However the changed output is getting sent to a new file called anotherletter.

sycamorex 01-15-2016 04:20 PM

This sed tutorial is considered by many the best sed resource out there:
http://www.grymoire.com/Unix/Sed.html

JockVSJock 01-15-2016 04:25 PM

Ya, I was just going to followup with a URL for learning SED. I'm sure there are more out there.

http://www.theunixschool.com/2012/06...e-line-or.html

Saro 01-15-2016 04:36 PM

Thank you guys, really helped.

grail 01-16-2016 03:26 AM

Please mark as SOLVED once you have your solution :)


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