Skip to content
Advertisement

Append input URL from user to variable in file using shell script

I have one file test.txt it have already some data named export website_URL and export username=

test.txt

JavaScript

start.sh

JavaScript

here creating new file from test.txt writing data in to data.txt file

JavaScript

here if I put input to website_URL=”http://stackoverflow.com/questions/6543841/php-cli-getting-input-from-user-and-then-dumping-into-variable-possible” it is failing with sed: -e expression #1, char 71: unknown option to `s’ this error . So I can store any url value in website_URL variable ? Is anything I am missing please let me know because it is able to store value for username and port

Advertisement

Answer

This is because of backslash in URL’s

url=echo $website_URL= | sed -e "s///\\\\//g"

sed -i ‘s/website_URL=*/website_URL=’$url’/’ $new_file

try this it will work in your case.

Advertisement