learnbyexample
Interests: Regular Expressions, Linux CLI one-liners, Scripting Languages and Vim
- 81 Posts
- 19 Comments
learnbyexample@programming.devOPto
Linux@lemmy.ml•Learn GNU sed with hundreds of examples and exercisesEnglish
1·1 year agoThanks a lot for the feedback :)
learnbyexample@programming.devto
Linux@lemmy.ml•[Solved] Convert commonmark links to Headings with spaces to GitHub flavored markdown.English
1·1 year agoWell, I’m not going to even try understanding the various features used in that
sedcommand. 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.English
2·1 year 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.English
1·1 year 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.English
1·1 year 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.txteflag allows you to use Perl code in the substitution portion.\[[^]]+\]\(\Kmatch square brackets and use\Kto mark the start of matching portion (text before that won’t be part of$&)(?!https?)don’t match ifhttporhttpsis found[^)]+(?=\))match non)characters and assert that)is present after those characters$&=~s|%20|-|grchange%20to-for the matching portion found, therflag is used to return the modified string instead of change$&itselflcis 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?"English
5·1 year agoGNU datamash (https://www.gnu.org/software/datamash/alternatives/) - handy tool for data munching. There’s also https://github.com/BurntSushi/xsv
learnbyexample@programming.devto
Linux@lemmy.ml•Which Linux tool or command is surprisingly simple, powerful, and yet underrated?"English
1·1 year agoCheck out my chapter on GNU grep BRE/ERE for those wanting to learn this regex flavor: https://learnbyexample.github.io/learn_gnugrep_ripgrep/breere-regular-expressions.html (there’s also another chapter for PCRE)
I use Vim ;)
Python itself provides IDLE, which is good enough for beginners. https://thonny.org/ is another good one for beginners.
As mentioned by others, Jetbrains is good for many languages. https://www.kdevelop.org/ is another option.
I have a list of learning resources for CLI tools and scripting here: https://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: https://github.com/learnbyexample/TUI-apps
learnbyexample@programming.devto
Linux@lemmy.ml•What are your must-have programs?English
2·2 years agooxipng, pngquant and svgcleaner for optimizing images
auto-editor for removing silent portions from video recordings
Not my blog, just sharing it here. Saw it on HN (https://news.ycombinator.com/item?id=40419325)
learnbyexample@programming.devOPto
Linux@lemmy.ml•CLI text processing with GNU Coreutils (head, tail, tr, sort, paste, pr, join, etc)English
3·2 years agoYeah, it is uncommon spelling, but if you google, you’ll find it’s not that rare ;)
learnbyexample@programming.devOPto
Linux@lemmy.ml•CLI text processing with grep, sed, awk, perl and rubyEnglish
5·2 years agoI had to learn Linux CLI tools, Vim and Perl at my very first job. Have a soft spot for Perl, despite not using it much these days other than occasional one-liners (mainly for advanced regex features).
learnbyexample@programming.devOPto
Linux@lemmy.ml•CLI text processing with grep, sed, awk, perl and rubyEnglish
2·2 years agoThanks! 😊
learnbyexample@programming.devOPto
Linux@lemmy.ml•Perl One-Liners Guide with plenty of examples and exercisesEnglish
2·3 years agoThat’s great to hear and thanks for the kind feedback :)
learnbyexample@programming.devOPto
Linux@lemmy.ml•Learn GNU awk with hundreds of examples and exercisesEnglish
3·3 years agoI’ve written books on regex too, if you are interested in learning ;)
See also:
- tldr — collection of community-maintained help pages for command-line tools
- explainshell — write down a command-line to see the help text that matches each argument
- General purpose command-line tools — examples for most common usecases
- Bash reference cheatsheet — nicely formatted and explained well
- Bash scripting cheatsheet — quick reference to getting started with Bash scripting
learnbyexample@programming.devto
Linux@lemmy.ml•Anyone know of a reverse command script or package to parse args for flags, expand them, and condense a man or help page(s) to just the relevant flags?English
1·3 years agoInspired by explainshell, I wrote a script (https://github.com/learnbyexample/command_help) to be used from the terminal itself. It is a bit buggy, but works well most of the time. For example:
$ ch grep -Ao grep - print lines that match patterns -A NUM, --after-context=NUM Print NUM lines of trailing context after matching lines. Places a line containing a group separator (--) between contiguous groups of matches. With the -o or --only-matching option, this has no effect and a warning is given. -o, --only-matching Print only the matched (non-empty) parts of a matching line, with each such part on a separate output line.







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.