sed command working in command line but not in script

8,471

There was nothing wrong with the code. I was simply editing a copy of the script instead of the one I was running.

Share:
8,471

Related videos on Youtube

To Do
Author by

To Do

Updated on September 18, 2022

Comments

  • To Do
    To Do over 1 year

    I have a script with the follow code:

    find . -name "*.html" -print0 | while IFS= read -r -d '' n; do
    sed -i -r 's/<font color="#bbbbbb">\.<\/font>.*?<input[^µ]*?mabulle\.hide\(\)">//1' "$n" 
    sed -i -r 's/<\/body>/<a href="\.\/00Tree\.html">Back<\/a><\/body>/' "$n" #add back link
    done
    

    The second sed is not working. If I run

    sed -i -r 's/<\/body>/<a href="\.\/00Tree\.html">Back<\/a><\/body>/' filename.html
    

    from the command line it works perfectly.

    The html files are named 0_name.html, 1_name.html, etc.

    What am I doing wrong?

    • oHo
      oHo almost 11 years
      Does your second sed works after processing the first one from command line? Can you give a tiny html sample to understand better the meaning of working?
    • To Do
      To Do almost 11 years
      Oh boy. I just discovered why it was working. I was editing a copy of the script, not the one I was running. I'm feeling stupid.
    • Rich Homolka
      Rich Homolka almost 11 years
      @ToDo glad you found it, please close the answer out.