[ACCEPTED]-Delete using a different delimiter with Sed-sed
// that you're using are not 17 for the
d command, they're for the addressing. I 16 think you're comparing them to the slashes 15 in the
s/// command... However although both 14 relate to regular expressions, they are 13 different contexts.
The address (which appears 12 before the command) filters which lines the command 11 is applied to... The options (which appear 10 after the command) are used to control the replacement 9 applied.
If you want to use different delimiters 8 for a regular expression in the address, you 7 need to start the address with a backslash:
$ sed '\:timebomb:d' test.txt 01 30 * * * /opt/reincarnate.sh >> reincarnation.log
(To 6 understand the difference between the address 5 and the options, consider the output of 4 the command:
$ sed '/timebomb/s/log/txt/' test.txt
The address chooses only the 3 line(s) containing the regular expression 2
timebomb, but the options tell the
s command to replace 1 the regular expression
The colon preceeds a label in sed, so your 4 sed program looks like a couple of labels 3 with nothing happening. The parser can see 2 colons as delimiters if preceded by the 1 s command, so that's a special case.
gawk '!/timebomb/' file > newfile
you can just use the shell, no need external 1 tools
while read -r line do case "$line" in *timebomb* ) continue;; *) echo "$line";; esac done <"file"
More Related questions