Delete using a different delimiter with Sed

The delimiters // that you’re using are not for the d command, they’re for the addressing. I think you’re comparing them to the slashes in the s/// command… However although both relate to regular expressions, they are different contexts.

The address (which appears before the command) filters which lines the command is applied to… The options (which appear after the command) are used to control the replacement applied.

If you want to use different delimiters for a regular expression in the address, you need to start the address with a backslash:

$ sed '\:timebomb:d' test.txt
  01 30 * * * /opt/reincarnate.sh >> reincarnation.log

(To understand the difference between the address and the options, consider the output of the command:

$ sed '/timebomb/s/log/txt/' test.txt

The address chooses only the line(s) containing the regular expression timebomb, but the options tell the s command to replace the regular expression log with txt.)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)