Solved

sed insert a string after pattern on same line

Posted on 2013-01-09
3
3,492 Views
Last Modified: 2013-01-09
Trying to use sed.

I can't figure out how to get sed to insert remember=5 after pattern sha512 in /etc/pam.d/system-auth file.

Thanks,

sed -i -e /sha512 / is my pattern and then don't know where to go from there. thanks.

the string in the file appears like this
                                                                             
                                                                               
password          sufficient       pam_unix.so sha512 shadow try_first_pass use_authtok
0
Comment
Question by:atom_jelly
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 500 total points
ID: 38760173
First do not use -i.  Use it when you are happy with the output

sed 's/\(sha512 \)/\1 remember=5/' /etc/pam.d/system-auth

Open in new window


Once it works, use -i option

sed  -i 's/\(sha512 \)/\1 remember=5/' /etc/pam.d/system-auth

Open in new window

0
 

Author Closing Comment

by:atom_jelly
ID: 38760219
Thanks, I was not even close to figuring it out but thats what asking and knocking is for.
0
 
LVL 31

Expert Comment

by:farzanj
ID: 38760231
Glad to help :)  Have a nice day!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to make a simple HTML bar chart with the usage of WhizBase, If you want more information about WhizBase please read my previous articles at http://www.experts-exchange.com/ARTH_5123186.html (http://www.experts-ex…
Recently, an awarded photographer, Selina De Maeyer (http://www.selinademaeyer.com/), completed a photo shoot of a beautiful event (http://www.sintjacobantwerpen.be/verslag-en-fotoreportage-van-de-sacramentsprocessie-door-antwerpen#thumbnails) in An…
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.

786 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question