learnbyexample
Interests: Regular Expressions, Linux CLI one-liners, Scripting Languages and Vim
- 43 Posts
- 8 Comments
learnbyexample@programming.devOPto Linux@lemmy.ml•I wrote an ebook on GNU awk with hundreds of examples and exercisesEnglish0·2 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).
learnbyexample@programming.devOPto Programming@programming.dev•Do-nothing scripting: the key to gradual automationEnglish0·3 months agoNot my site, just sharing a link I saw on HN.
learnbyexample@programming.devto Linux@lemmy.ml•[Solved] Convert commonmark links to Headings with spaces to GitHub flavored markdown.English0·3 months agoThis might work, but I think it is best to not tinker further if you already have a working script (especially one that you understand and can modify further if needed).
perl -pe 's/\[[^]]+\]\((?!https?)[^#]*#\K[^)]+(?=\))/lc $&=~s:%20|\d\K\.(?=\d):-:gr/ge'
learnbyexample@programming.devto Linux@lemmy.ml•[Solved] Convert commonmark links to Headings with spaces to GitHub flavored markdown.English0·3 months agoHmm, OP mentioned “Only edit what’s between parentheses” - don’t see anywhere that whole URL shouldn’t be changed…
learnbyexample@programming.devto Linux@lemmy.ml•[Solved] Convert commonmark links to Headings with spaces to GitHub flavored markdown.English0·3 months agoHere’s a solution with
perl
(assuming you don’t want to change http/https after the start of(
instead of start of a line):perl -pe 's/\[[^]]+\]\(\K(?!https?)[^)]+(?=\))/lc $&=~s|%20|-|gr/ge' ip.txt
e
flag allows you to use Perl code in the substitution portion.\[[^]]+\]\(\K
match square brackets and use\K
to mark the start of matching portion (text before that won’t be part of$&
)(?!https?)
don’t match ifhttp
orhttps
is found[^)]+(?=\))
match non)
characters and assert that)
is present after those characters$&=~s|%20|-|gr
change%20
to-
for the matching portion found, ther
flag is used to return the modified string instead of change$&
itselflc
is a function to change text to lowercase
learnbyexample@programming.devto Linux@lemmy.ml•Am I limited if I use ffmpeg for screen recording?English0·5 months agoI wish you success. I’m happy to use SimpleScreenRecorder(https://github.com/MaartenBaert/ssr).
learnbyexample@programming.devOPto Linux@lemmy.ml•I wrote a Vim Reference Guide (beginner to intermediate level)English0·9 months agoWhy do you think it is a phishing link? Gumroad is a well known platform to sell digital goods.
I mention it is free up to some date because it will go back to being a paid product after that.
Thanks a lot for the feedback :)