learnbyexample
Interests: Regular Expressions, Linux CLI one-liners, Scripting Languages and Vim
- 21 Posts
- 4 Comments
Regex syntax and features vary between implementations.
\d
isn’t supported by BRE/ERE flavors.GNU grep
supports 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 exercisesEnglish2·2 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 exercisesEnglish0·3 months agoWell, if you are comfortable with Python scripts, there’s not much reason to switch to
awk
. Unless perhaps you are equatingawk
to 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
awk
to 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?