Table of Contents
alias hd='sudo hdparm -Y /dev/sda'
.
² Delete lines #
whole lines beginning with <
1^<.*\n?
2# ^ start of line
3# < literal <
4# .* rest of line
5# \n? also remove the newline so you don’t leave blank lines
delete any empty line (even lines with spaces):
1^\s*\n
2# ^\s* matches zero or more whitespace chars from the start of the line
3# \n removes the actual newline
only truly empty lines (no spaces):
1^\n
.
² Find #
³ Find foo OR bar #
1find . \( -name "*.htm" -o -name "*.html" \) # Shell cant eat parentheses
2
3# alternative
4find . -regex '.*\.html?'
³ Dont descend into dirs on other FS #
1find ~ -mount -print
2find ~ -xdev -print
Symlinked dirs - but prunes also symlinked files :(
1find ~ -type l -prune -o -print
Combine tests to prune only symlinked dirs:
1find ~ -type l -a -xtype d -prune -o -print
2
3#=> -type l # matches symlinks
4#=> -xtype d # checks if symlink points to dir
5#=> -a # -and (logical AND : both conditions be true)
6#=> -prune # skips those symlinked dirs
7#=> -o -print # prints everything else
Solution: Combine exclusion of mounted filesystems and symlinked dirs
1find ~ -xdev -type l -a -xtype d -prune -o -print
.
² NTFY.sh #
f_ntfy (){ curl -d "$1" ntfy.sh/divienne ;}
.
² MPV #
1
2_useragent='Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
3
4mpv --user-agent="$_useragent" <URL>
5
6# or
7cat << EOG >> ~/.config/mpv/mpv.conf
8user-agent="_useragent"
9EOG
.
² SORT : Dont ignore '#' #
FROM TO
----------------
aaa #aaa
#aaa #bbb
bbb aaa
#bbb bbb
- Compare first char
- If equal → compare the rest
Syntax:
sort -k START[,END] [-k START[,END]]
Where:
. START + END = field chars
. Fields separated by whitespace (default)
. chars are 1-based
Method: 2 sort keys, applied one after another
sort -k 1.1,1.1 -k 1.2
Grouping: FROM field 1, char 1 TO field 1, char 1
Key 1: -k 1.1,1.1
Sorting inside groups : field 1, char 2
Key 2: -k 1.2
.
² "Watchdogs" ;) #
inotify
sudo pacman -S inotify-tools
which inotifywait
inotifywait --version
alternatives
entr
1# install
2sudo pacman -Qs entr
3# eg
4ls ~/blog-local/*.md | entr -r rsync -av --exclude='.~*' ~/blog-local/ ~/blog-remote/
5# cons
6# needs eg `ls` -- no auto detect
systemd.path
watch dirs -> trigger service
see https://eog.prose.sh/cmp.cmd..systemd.path..watch.dir.and.sync
.
² YAML #
https://developers.machinemetrics.com/docs/adapter-scripts/yaml
array inline
1#
2tags: [feature, announcement]
is same as
1tags:
2 - feature
3 - announcement
Indent w/ min. 2 spaces. But NO TABS allowed!!
1authors: # = key
2 - name: Alice # = object / map
3 role: writer # belongs to this object
4 socials:
5 twitter: alice42
6
7 - name: Bob
8...
1authors =
2[
3 { name: "Alice", role: "writer", socials: {twitter:"alice42"} },
4 { name: "Bob", role: "editor", socials: {twitter:"bob_edit"} }
5]
Tips
indentation 2 spaces at each level.
