the ‘d’ command in the sed utility

It means that sed will read the next line and start processing it.

Your test script doesn’t do what you think. It matches the empty lines and applies the delete command to them. They don’t appear, so the print statements don’t get applied to the empty lines. The two print commands aren’t connected to the pattern for the delete command, so the non-empty lines are printed three times. If you instead try

sed '/./d;p;p' test.txt # matches all non-empty lines

nothing will be printed other than the blank lines, three times each.

Leave a Comment