Solved

use of sed to replace a line in a file

Posted on 2013-05-31
3
553 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
[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
3 Comments
 
LVL 3

Assisted Solution

by:PtitPinpin
PtitPinpin earned 250 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 84

Accepted Solution

by:
ozo earned 250 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

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Utilizing an array to gracefully append to a list of EmailAddresses
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.:
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Suggested Courses

739 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