I want to be able to pass in $1 into this command that I am running, but I think it is trying it literally as opposed to using the value of $1:
find /test/$1 -type f -name ‘*.html’ | xargs sed -i -r ‘s/href=”http://$1//href=”://g’
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.
Yes; single quotes prevent variable expansion. You need to use double quotes, but because you are also using them literally we need to switch quoting styles mid-stream. And I’m unclear as to how you expected slashes to work simultaneously as regex delimiters and data:
You will also need to watch out that
$1doesn’t contain any regex special characters, and if it might contain a comma then you will probably want to use something else as the regex delimiter.