4 ms·
Nice descriptions, but some of them need changes to match the command. For example: sed '1~2p' file.txt #needs -n option s '1,$ s/foo/bar/' file.txt #
by asicsp 5y ago
Nice descriptions, but some of them need changes to match the command. For example:
sed '1~2p' file.txt #needs -n option
s '1,$ s/foo/bar/' file.txt #s --> sed and 1,$ --> 5,$
Many commands using `-r` do not need the option for the command used (for ex: `sed -r '/start/q'`). Also, using `-E` is preferred instead of `-r` since some of the other implementations support this option but not `-r`.
---
I wrote a book on GNU sed with plenty of examples and exercises: https://github.com/learnbyexample/learn_gnused https://github.com/learnbyexample/learn_gnused It is free to read online and there's a detailed chapter for learning BRE/ERE regex flavor as well.
- adrianscheff 5y agoThank you for the constructive feedback, I've corrected the mistakes pointed out. I've also changed -r to -E based on your (and some other people's) advice.