Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

use of sed to replace a line in a file

Posted on 2013-05-31
3
Medium Priority
?
570 Views
Last Modified: 2013-05-31
Im trying to run this string to update a file using sed but I'm getting an error, any help is appreciated.

sed -i 's/^user:$2a$10$xDaSTFrgvbBLei/sKK3sWeVVwJBUGTJjEn/AxrTCrdlZhm4aLVsI2:15854::::::/user:$2a$10$oQXSUBcZBognRNghQ63GBexOg8sX1gZuks06xRRO9BXdWQrZinI3u:15856::::::/' /etc/shadow

error returned is
sed: -e expression #1, char 51: unknown option to `s'

Regards,
0
Comment
Question by:atorex
3 Comments
 
LVL 3

Assisted Solution

by:PtitPinpin
PtitPinpin earned 1000 total points
ID: 39211190
Hi,

i think you should take care of / and $ in your password hash...
sed -i 's/^user:\$2a\$10\$xDaSTFrgvbBLei\/sKK3sWeVVwJBUGTJjEn\/AxrTCrdlZhm4aLVsI2:15854::::::/user:\$2a\$10\$oQXSUBcZBognRNghQ63GBexOg8sX1gZuks06xRRO9BXdWQrZinI3u:15856::::::/' /etc/shadow

Regards
0
 
LVL 85

Accepted Solution

by:
ozo earned 1000 total points
ID: 39211322
sed -i 's#^user:$2a$10$xDaSTFrgvbBLei/sKK3sWeVVwJBUGTJjEn/AxrTCrdlZhm4aLVsI2:15854::::::#user:$2a$10$oQXSUBcZBognRNghQ63GBexOg8sX1gZuks06xRRO9BXdWQrZinI3u:15856::::::/# /etc/shadow
0
 

Author Closing Comment

by:atorex
ID: 39211402
thanks
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Google Drive is extremely cheap offsite storage, and it's even possible to get extra storage for free for two years.  You can use the free account 15GB, and if you have an Android device..when you install Google Drive for the first time it will give…
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.:
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses
Course of the Month7 days, 6 hours left to enroll

783 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