diff options
-rw-r--r-- | awk.md | 52 | ||||
-rw-r--r-- | bash.md | 30 | ||||
-rw-r--r-- | certbot.md | 6 | ||||
-rw-r--r-- | ffmpeg.md | 24 | ||||
-rw-r--r-- | file-operations.md | 13 | ||||
-rw-r--r-- | imagemagick.md | 4 | ||||
-rw-r--r-- | ledger.md | 6 | ||||
-rw-r--r-- | mutt.md | 4 | ||||
-rw-r--r-- | pacman.md | 12 | ||||
-rw-r--r-- | pdf.md | 10 |
10 files changed, 158 insertions, 3 deletions
@@ -13,4 +13,54 @@ Program is ;-separated pattern-action statements. `$0` is whole line, `$1`, `$2`, ... are fields separated by `FS` (by default, whitespace). -Set `FS` with `-F <sepstring>` +Set `FS` with `-F <sepstring>`. This can be a regular expression. + +Actually, the first part is any *condition*, and a /grep/ pattern is just one +possible one. Another useful example: `awk '$2 > 100 { print $3 }'`: print the +third column, if the line's second column is greater than 100. + +## Flags + +* `-F`: set the field separator, `FS` +* `-v`: set any variable + +## Conditions + +* Numerical comparisons: `==`, `!=`, `>`, `>=`, `<`, `<=` +* Regex matches: `~`, `!~` +* Logical operators: `&&`, `||`, `!` + +Special conditions: + +* `BEGIN`: triggered before processing any lines +* `END`: triggered after processing all lines + +If multiple conditions match, each action will be executed for it. In +particular, if multiple actions print, each will print. `next` can come in +useful, skipping all other conditions. + +## Built in Variables + +* `NR`: number of lines processed so far +* `NF`: number of fields (columns) in current line +* `FS`: input field separator, used to split each line into fields. +* `OFS`: output field separator, i.e. what gets printed between comma-separated + items in a `print` statement. Default: ' ' (space). Typical pattern: set it to + something else in a BEGIN block or with the `-v` flag. + +Useful when processing multiple files: + +* `FNR`: like `NR`, resets to 0 on new file +* `FILENAME`: name of currently processed file (`-` when STDIN) + +## Actions + +* `next`: skips processing of following conditions +* `exit`: finish processing (`END` will be executed) +* `printf`: formatted printing + +## Arrays + +* They're really more like hashmaps. +* Index with `[]`. +* Iterate over keys: `for(x in arr) print x, arr[x]` @@ -66,6 +66,9 @@ Associative arrays: Assignment: + # Indexed + array=(foo bar "baz bom"...) + # Associative array=([bla]=foo [ble]=bar...) All values: @@ -78,6 +81,23 @@ All keys: ${!array[*]} ${!array[@]} +So looping: + + # Over values + for x in "${array[@]}"; do ... + # Over keys (0-based indices for indexed) + for x in "${!array[@]}"; do ... + + +Array size: + + ${#array[@]} + +Slice: + + # n elements starting at index i + ${array[@]:i:n} + ## Commandline arguments * `$#`: number of arguments. @@ -99,3 +119,13 @@ Positional arguments will have to be supplied after flag options (`command [options] <args>`): shift $((OPTIND-1)) + + +## Shell optional behavior/settings/options (`shopt` builtin) + + # Enable + shopt -s <option> + # Disable + shopt -u <option> + +* `nocaseglob`: glob matching is case insensitive diff --git a/certbot.md b/certbot.md new file mode 100644 index 0000000..5d8de41 --- /dev/null +++ b/certbot.md @@ -0,0 +1,6 @@ +# Free SSL certificates with Let's Encrypt + +## Multiple domains on one certificate + + # Can be used alongside with e.g. `--nginx` + certbot -d domain1.tld,domain2.tld,... @@ -24,6 +24,14 @@ Works for audio, too. * `-b:a 192k`: specify audio bitrate to 192 kbps * `-b:v 2M`: specify video bitrate to 2 mbps +### Encoding + +H.265 is one of the top recommended formats, for size:quality ratio. + + ffmpeg -i in.mp4 -vcodec libx265 -crf <value> out.mp4 + +Reasonable `crf` values could be 24 to 30. + ## Audio/video delay ffmpeg -i "$input" -itsoffset <offset in seconds> -i "$input" -map 1:v -map 0:a -c:a copy -c:v libx264 "$output" @@ -61,7 +69,21 @@ For the transpose parameter you can pass: ## Concatanate audio - ffmpet -i in1.mp3 -i in2.mp3 -i in3.mp3 -filter_complex '[0:0][1:0][2:0]concat=n=3:v=0:a=1' output.mp3 + ffmpeg -i in1.mp3 -i in2.mp3 -i in3.mp3 -filter_complex '[0:0][1:0][2:0]concat=n=3:v=0:a=1' output.mp3 + +## Concatanate videos + +Works well especially for large number. + +Create file `list.txt` + + file 'video1.mp4' + file 'video2.mp4' + ... + +Then + + ffmpeg -f concat -i list.txt -c copy combined.mp4 ## Fitlering diff --git a/file-operations.md b/file-operations.md new file mode 100644 index 0000000..9ed0441 --- /dev/null +++ b/file-operations.md @@ -0,0 +1,13 @@ +# General file operations and utilities + +## `shred` + +Overwrites a file repeatedly with random data, to prevent data recovery. + +* `-z`: zeroes out at the end +* `-n <N>`: does `N` iterations (deafults to only 3) +* `-u`: deallocates and removes file + +So a common usage: + + shred -zun100 <file> diff --git a/imagemagick.md b/imagemagick.md index f4783df..3985c73 100644 --- a/imagemagick.md +++ b/imagemagick.md @@ -31,3 +31,7 @@ List possible option values convert -list <option> # e.g. convert -list dither + +## Remove EXIF data + + convert in.jpg -strip out.jpg @@ -2,4 +2,8 @@ ## Dates -* `--beging/--end` (`-b/-e`): date bounds +* `--begin/--end` (`-b/-e`): date bounds + +## List transactions + + ledger print <account> @@ -13,3 +13,7 @@ After composing message, press `p` to select crypto actions. ## Search patterns - `~C`: search in TO and CC fields + +## Marking + +`exec toggle-new` to toggle read/unread status @@ -41,6 +41,18 @@ there and remove the .pacnew suffix) By itself, outputs all installed packages. +### Info + +Includes provided binaries/libraries, dependencies, installed size, etc. + + pacman -Qi <package> + + +Double info, includes more information, including packages that require (depend +on) this one: + + pacman -Sii <package> + ### Browsing installed packages with `fzf` pacman -Qq | fzf --preview 'pacman -Qil {}' --layout=reverse --bind 'enter:execute(pacman -Qil {} | less)' @@ -15,3 +15,13 @@ ## Images to pdf convert in1.jpg in2.jpg out.pdf + +## DjVu to pdf + + ddjvu -format=pdf file.fjvu file.pdf + +* `-quality=85`: can be used to produce smaller output + * `-quality=uncompressed`: disable compression +* `-page=23-48,59`: select pages to convert +* `-verbose` +* `-eachpage`: generates a separate file per page |