Solved

sed insert a string after pattern on same line

Posted on 2013-01-09
3
3,355 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Attention: This article will no longer be maintained. If you have any questions, please feel free to mail me. jgh@FreeBSD.org Please see http://www.freebsd.org/doc/en_US.ISO8859-1/articles/freebsd-update-server/ for the updated article. It is avail…
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…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

910 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

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now