diff options
-rw-r--r-- | awk.md | 52 | ||||
-rw-r--r-- | ffmpeg.md | 16 | ||||
-rw-r--r-- | file-operations.md | 13 | ||||
-rw-r--r-- | pdf.md | 10 |
4 files changed, 89 insertions, 2 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]` @@ -69,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> @@ -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 |