I’m writing the following script:
v="1,pop";
sed "$v/d" dir/file1
It gives me this error:
char 3: unexpected `,'
How to solve this? Note: the value of $v cannot be controlled.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You are using
sedin a wrong way.If you want to substitute a bash variable inside
sed, you need to surround it with quotes like I showed above. Also if you want to write modification to file, you need to usesedwith-i.