Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

sed insert a string after pattern on same line

Posted on 2013-01-09
3
Medium Priority
?
4,789 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Using libpcap/Jpcap to capture and send packets on Solaris version (10/11) Library used: 1.      Libpcap (http://www.tcpdump.org) Version 1.2 2.      Jpcap(http://netresearch.ics.uci.edu/kfujii/Jpcap/doc/index.html) Version 0.6 Prerequisite: 1.      GCC …
Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

610 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