475
199
49
Writing Toy Software Is A Joy (www.jsbarretto.com)
59

Regex syntax and features vary between implementations. \d isn't supported by BRE/ERE flavors.

GNU grep supports PCRE, so you can use grep -oP '/dev/loop\d' or grep -o '/dev/loop[0-9]' if you are matching only one digit character.

86
19
46
129
169
61
18
38

Well, if you are comfortable with Python scripts, there's not much reason to switch to awk. Unless perhaps you are equating awk to Python as scripting languages instead of CLI usage (like grep, 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.dev 6 points 2 years ago

I wish you success. I'm happy to use SimpleScreenRecorder(https://github.com/MaartenBaert/ssr).

[-] learnbyexample@programming.dev 5 points 2 years ago

I 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.dev 6 points 2 years ago

I have a list of curated resources here: https://learnbyexample.github.io/py_resources/

There are sections for beginners, intermediate, advanced, etc. Also included are exercises, projects, debugging, testing, and many more stuff. Hope it helps :)

[-] learnbyexample@programming.dev 7 points 2 years ago* (last edited 2 years ago)
alias a='alias'

a c='clear'
a p='pwd'
a e='exit'
a q='exit'

a h='history | tail -n20'
# turn off history, use 'set -o history' to turn it on again
a so='set +o history'

a b1='cd ../'
a b2='cd ../../'
a b3='cd ../../../'
a b4='cd ../../../../'
a b5='cd ../../../../../'

a ls='ls --color=auto'
a l='ls -ltrhG'
a la='l -A'
a vi='gvim'
a grep='grep --color=auto'

# open and source aliases
a oa='vi ~/.bash_aliases'
a sa='source ~/.bash_aliases'

# sort file/directory sizes in current directory in human readable format
a s='du -sh -- * | sort -h'

# save last command from history to a file
# tip, add a comment to end of command before saving, ex: ls --color=auto # colored ls output
a sl='fc -ln -1 | sed "s/^\s*//" >> ~/.saved_commands.txt'
# short-cut to grep that file
a slg='< ~/.saved_commands.txt grep'

# change ascii alphabets to unicode bold characters
a ascii2bold="perl -Mopen=locale -Mutf8 -pe 'tr/a-zA-Z/๐—ฎ-๐˜‡๐—”-๐—ญ/'"

### functions
# 'command help' for command name and single option - ex: ch ls -A
# see https://github.com/learnbyexample/command_help for a better script version
ch() { whatis $1; man $1 | sed -n "/^\s*$2/,/^$/p" ; }

# add path to filename(s)
# usage: ap file1 file2 etc
ap() { for f in "$@"; do echo "$PWD/$f"; done; }

# simple case-insensitive file search based on name
# usage: fs name
# remove '-type f' if you want to match directories as well
fs() { find -type f -iname '*'"$1"'*' ; }

# open files with default application, don't print output/error messages
# useful for opening docs, pdfs, images, etc from command line
o() { xdg-open "$@" &> /dev/null ; }

# if unix2dos and dos2unix commands aren't available by default
unix2dos() { sed -i 's/$/\r/' "$@" ; }
dos2unix() { sed -i 's/\r$//' "$@" ; }
[-] learnbyexample@programming.dev 6 points 3 years ago* (last edited 3 years ago)

Check out https://github.com/auctors/free-lunch (list of free Windows software)

See also https://www.nirsoft.net/ (freeware, not open source)

[-] learnbyexample@programming.dev 5 points 3 years ago

I've written books on regex too, if you are interested in learning ;)

[-] learnbyexample@programming.dev 6 points 3 years ago

I read three progression fantasy books in the past three days, so I'm going to take a break and get some of my actual work done :D

Card Mage: Slumdog Deckbuilder by Benedict Patrick (book 1 of a new series) was well written and a compelling read, but I'd have enjoyed it a lot more if it was lighthearted.

Overpowered Dungeon Boy by Benjamin Barreth (2 book completed series) was a lighthearted fun read. The OP main character took a while to warm up to, but many of the side characters were easy to root for.

[-] learnbyexample@programming.dev 7 points 3 years ago

Yeah, PCC is a good choice. Make sure to type examples codes manually (i.e. don't just read them) and try to solve all the exercises. Since you mention you want to learn it as a hobby, "Automate the Boring Stuff with Python" (2nd edition) would be a good choice as well, as you might find some of the projects in the second half helpful.

view more: โ€น prev next โ€บ

learnbyexample

0 post score
0 comment score
joined 3 years ago