learnbyexample
Interests: Regular Expressions, Linux CLI one-liners, Scripting Languages and Vim
GitHub: http://github.com/learnbyexample
- 176 Posts
- 97 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 exercisesEnglish1·3 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 exercisesEnglish1·3 months agoAlready done grep, sed, coreutils, cli basics and more. See http://learnbyexample.github.io/learn_gnuawk/buy.html#book-list for links.
learnbyexample@programming.devOPto Linux@lemmy.ml•I wrote an ebook on GNU awk with hundreds of examples and exercisesEnglish6·4 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.devto Books@lemmy.ml•Suggest me some books (Sci fi/Fantasy)English2·4 months agoI’ll recommend some from the lesser known progression fantasy genre:
- Cradle by Will Wight
- Mage Errant by John Bierce
- Mother of Learning by Nobody103 (Domagoj Kurmaić)
- The Weirkey Chronicles by Sarah Lin
- Beware of Chicken by CasualFarmer
- Super Powereds by Drew Hayes
learnbyexample@programming.devOPto Programming@programming.dev•Do-nothing scripting: the key to gradual automationEnglish2·5 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.English1·5 months agoWell, I’m not going to even try understanding the various features used in that
sed
command. I do know how to use basic loops with labels, but I never bothered with all the buffer manipulation stuff. I’d rather use awk/perl/python for those cases.
learnbyexample@programming.devto Linux@lemmy.ml•[Solved] Convert commonmark links to Headings with spaces to GitHub flavored markdown.English2·5 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/\[[^]]+\]\((?!http?)[^#]*#\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.English1·5 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.English2·5 months agoHere’s a solution with
perl
(assuming you don’t want to change http/http after the start of(
instead of start of a line):perl -pe 's/\[[^]]+\]\(\K(?!http?)[^)]+(?=\))/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$&
)(?!http?)
don’t match ifhttp
orhttp
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•Which Linux tool or command is surprisingly simple, powerful, and yet underrated?"English7·6 months agoGNU datamash (http://www.gnu.org/software/datamash/alternatives/) - handy tool for data munching. There’s also http://github.com/BurntSushi/xsv
learnbyexample@programming.devto Linux@lemmy.ml•Which Linux tool or command is surprisingly simple, powerful, and yet underrated?"English2·6 months agoCheck out my chapter on GNU grep BRE/ERE for those wanting to learn this regex flavor: http://learnbyexample.github.io/learn_gnugrep_ripgrep/breere-regular-expressions.html (there’s also another chapter for PCRE)
learnbyexample@programming.devto Books@lemmy.ml•Fantasy books with an interesting "soft magic" system?English31·6 months agoMemory, Sorrow, and Thorn by Tad Williams
I use Vim ;)
Python itself provides IDLE, which is good enough for beginners. http://thonny.org/ is another good one for beginners.
As mentioned by others, Jetbrains is good for many languages. http://www.kdevelop.org/ is another option.
learnbyexample@programming.devto Linux@lemmy.ml•Am I limited if I use ffmpeg for screen recording?English6·7 months agoI wish you success. I’m happy to use SimpleScreenRecorder(http://github.com/MaartenBaert/ssr).
learnbyexample@programming.devOPto Python@programming.dev•All About Decorators in PythonEnglish2·8 months agoI’m not the site author, just submitting the link.
Not sure which part you need to be logged in to view - I’m seeing links to different articles and exercises and they are all visible without logging (I checked in an incognito window).
I have a list of learning resources for CLI tools and scripting here: http://learnbyexample.github.io/curated_resources/linux_cli_scripting.html
I’ve also written a few TUI interactive apps to practice text processing commands like grep, sed, awk, coreutils, etc: http://github.com/learnbyexample/TUI-apps
learnbyexample@programming.devOPto Linux@lemmy.ml•I wrote a Vim Reference Guide (beginner to intermediate level)English1·11 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.
Why would it print the colon?