?
Solved

sed insert a string after pattern on same line

Posted on 2013-01-09
3
Medium Priority
?
4,487 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 31

Accepted Solution

by:
farzanj earned 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

FreeBSD on EC2 FreeBSD (https://www.freebsd.org) is a robust Unix-like operating system that has been around for many years. FreeBSD is available on Amazon EC2 through Amazon Machine Images (AMIs) provided by FreeBSD developer and security office…
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…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
Suggested Courses

762 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