learnbyexample
Interests: Regular Expressions, Linux CLI one-liners, Scripting Languages and Vim
- 32 Posts
- 4 Comments
Regex syntax and features vary between implementations.
\disn’t supported by BRE/ERE flavors.GNU grepsupports PCRE, so you can usegrep -oP '/dev/loop\d'orgrep -o '/dev/loop[0-9]'if you are matching only one digit character.
learnbyexample@programming.devOPto
Linux@lemmy.ml•Learn GNU sed with hundreds of examples and exercisesEnglish
2·7 months agoThanks a lot for the feedback :)
learnbyexample@programming.devOPto
Linux@lemmy.ml•I wrote an ebook on GNU awk with hundreds of examples and exercisesEnglish
0·8 months agoWell, if you are comfortable with Python scripts, there’s not much reason to switch to
awk. Unless perhaps you are equatingawkto Python as scripting languages instead of CLI usage (likegrep,sed,cut, etc) as my ebook focuses on. For example, if you have space separated columns of data,awk '{print $2}'will give you just the second column (no need to write a script when a simple one-liner will do). This of course also allows you to integrate with shell features (like globs).As a practical example, I use
awkto filter and process particular entries from financial data (which is in csv format). Just a case of easily arriving at a solution in a single line of code (which I then save it for future use).





Why would it print the colon?