sed operation

What does the s and g used in the following expression ? Tks
sed 's/-error_log//g'`
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

man sed
s/regular expression/replacement/flags
Substitute the replacement string for the first instance of the regular expression in the pattern space.
The value of flags in the substitute function is zero or more of the following:
                   g       Make the substitution for all non-overlapping matches of the regular expression, not just the first one.
AXISHKAuthor Commented:
can't get the concept. Is there any example to illustrate more ? Tks
echo 'aaa-error_logbbb-error_logccc' | sed 's/-error_log//g'
IT Pros Agree: AI and Machine Learning Key

We’d all like to think our company’s data is well protected, but when you ask IT professionals they admit the data probably is not as safe as it could be.

Terry WoodsIT GuruCommented:
g is short for global I understand. Without it just the first match would be substituted.
Gerwin Jansen, EE MVETopic Advisor Commented:
sed is a stream editor, you send text to it, either from a file or using echo as demonstrated above.

The most basic use of sed is searching for and replacing text in the stream, so if  you send it:

"hello AXISHK" and you want to replace hello with goodbye then you do this:
echo "hello AXISHK" | sed 's/hello/goodbye/'

Open in new window

 resulting in: "goodbye AXISHK"

sed then replaces the first occurrence of the word hello on a line with goodbye

If you want to replace every hello on a line you add g at the end (g = global)

If you want to delete (or replace with nothing) then you leave out the word goodbye, you then get:
echo "hello AXISHK" | sed 's/hello//'

Open in new window

 resulting in: " AXISHK" (note the space at the begin)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AXISHKAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.