LinuxQuestions.org
Review your favorite Linux distribution.
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 01-15-2016, 04:06 PM   #1
Saro
LQ Newbie
 
Registered: Jan 2016
Posts: 7

Rep: Reputation: Disabled
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
 
Old 01-15-2016, 04:16 PM   #2
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,301
Blog Entries: 4

Rep: Reputation: 148Reputation: 148
Quote:
Originally Posted by Saro View Post
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.
 
Old 01-15-2016, 04:20 PM   #3
sycamorex
LQ Veteran
 
Registered: Nov 2005
Location: London
Distribution: Slackware64-current
Posts: 5,833
Blog Entries: 1

Rep: Reputation: 1229Reputation: 1229Reputation: 1229Reputation: 1229Reputation: 1229Reputation: 1229Reputation: 1229Reputation: 1229Reputation: 1229
This sed tutorial is considered by many the best sed resource out there:
http://www.grymoire.com/Unix/Sed.html
 
Old 01-15-2016, 04:25 PM   #4
JockVSJock
Senior Member
 
Registered: Jan 2004
Location: SATX
Distribution: RHEL/CentOS
Posts: 1,301
Blog Entries: 4

Rep: Reputation: 148Reputation: 148
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
 
Old 01-15-2016, 04:36 PM   #5
Saro
LQ Newbie
 
Registered: Jan 2016
Posts: 7

Original Poster
Rep: Reputation: Disabled
Thank you guys, really helped.
 
Old 01-16-2016, 03:26 AM   #6
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,719

Rep: Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034Reputation: 3034
Please mark as SOLVED once you have your solution
 
  


Reply


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
Sed substitution gives error "sed: command garbled" gsai0205 Linux - Newbie 3 09-13-2013 09:01 AM
[SOLVED] sed gives :sed: -e expression #1, char 1: unknown command: `'' samasat Linux - Newbie 10 06-09-2012 05:31 PM
[SOLVED] sed help to run sed command against multiple different file names bkone Programming 2 04-16-2012 12:27 PM
Sed command - command garbled errror gauavmahesh Linux - Newbie 3 03-30-2012 10:04 PM
Modifying text file with "one command line" SED command... daleo Linux - Newbie 3 01-13-2012 05:32 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:50 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration