Home > Back-end >  Linux .sh file with grep
Linux .sh file with grep

Time:09-01

I am trying to edit an existing Linux .sh script that uses grep. I need to remove or comment out some lines that use the -e command line option. When I delete or comment out a line, I get error command not found on the line before the one deleted or commented out. To comment out I just put # in front of line. If I delete it, I am not touching any of the surrounding lines. Why would I be getting a command not found error? Thanks Lele

Code below: for example, I want to remove the line that searches for child.

`rga -S --binary --rga-adapters= pdfpages,tesseract -M=250 --max 
columns-preview --max-count 20 --heading -H -w -P e'accommodation'\ 
-e 'child(?!\<)(?!>)(?!=)' \
-e '[\w] [\\@][a-z]{1,30}[\.][a-z]{3}' \
-e '[0-9]{3}[-|\s][0-9]{2}[-|\s][0-9]{4}' \
-e '[\\(]?[0-9]{3}[\\)]?[\s|\-]?[0-9]{3}[\-][0-9]{4}' \
-e '[0-9]{3}[\-|\s][0-9]{4}' \`

CodePudding user response:

You can't put a comment in the middle of a command. So you have to remove the child line completely. If you want to keep track of what you removed, you can add that as a separate comment

`rga -S --binary --rga-adapters= pdfpages,tesseract -M=250 --max 
columns-preview --max-count 20 --heading -H -w -P e'accommodation'\ 
-e '[\w] [\\@][a-z]{1,30}[\.][a-z]{3}' \
-e '[0-9]{3}[-|\s][0-9]{2}[-|\s][0-9]{4}' \
-e '[\\(]?[0-9]{3}[\\)]?[\s|\-]?[0-9]{3}[\-][0-9]{4}' \
-e '[0-9]{3}[\-|\s][0-9]{4}' \`

# removed this:
# -e 'child(?!\<)(?!>)(?!=)' \
  • Related