diff options
| -rw-r--r-- | audio.md | 4 | ||||
| -rw-r--r-- | awk.md | 52 | ||||
| -rw-r--r-- | ffmpeg.md | 16 | ||||
| -rw-r--r-- | file-operations.md | 13 | ||||
| -rw-r--r-- | git.md | 2 | ||||
| -rw-r--r-- | locale.md | 4 | ||||
| -rw-r--r-- | pdf.md | 10 | ||||
| -rw-r--r-- | ranger.md | 1 | ||||
| -rw-r--r-- | rsync.md | 23 | ||||
| -rw-r--r-- | xdg-open.md | 7 |
10 files changed, 129 insertions, 3 deletions
@@ -6,3 +6,7 @@ * `-w` for WAV output * `-B` for batch mode (output to one file per track) + +## Inspecting audio files with `soxi` + +* `-d`/`-D`: duration in hours:minutes:seconds/seconds. @@ -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,7 +15,7 @@ git bisect new git checkout <some commit a while ago> git bisect old - git bisect run <command that returns 1 on old, 0 on new> + git bisect run <command that returns 0 on old, 1 on new> ## Patches @@ -17,3 +17,7 @@ both the `en_US` and `pl_PL` utf8 locales, then create a `.config/locale.conf`: # /etc/vconsole.conf KEYMAP=pl2 FONT=lat2-16 + +For high DPI displays (needs `terminus-font` package): + + FONT=ter-v32n @@ -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 @@ -39,3 +39,4 @@ Files can have a single arbitrary tag, persistent between restarts. * `uv` - deselect all * Or `:unmark` * Can also use `:unmark <regex>` +* `:mark <regex>`: selects all matching files diff --git a/rsync.md b/rsync.md new file mode 100644 index 0000000..9e2c2a3 --- /dev/null +++ b/rsync.md @@ -0,0 +1,23 @@ +# rsync + + rsync from/dir to/location + +Copies files, creating `to/location/dir` + + rsync from/dir/ to/location + +Copies the contents of `from/dir` to `to/location/` + +## Options + +Basic ones: + +- `-r/--recursive`: recurses directories +- `-v/--verbose`: increases verbosity +- `--delete`: deletes files from destination that weren't in the source +- `-z/--compress`: compress files during transfer + +### -a / --archive + +Turns on `-rlptgoD`. So recursive (`-r`), and preserves a bunch of stuff like +soft links, permissions, owners, modification times, special files. diff --git a/xdg-open.md b/xdg-open.md index a688517..6113679 100644 --- a/xdg-open.md +++ b/xdg-open.md @@ -6,6 +6,13 @@ to open it. The local database for applications to use is in `~/.config/mimeapps.list`. Need a `.desktop` file, which can be created under `~/.local/share/applications/`. +## Checking the database + + # Looks up program to open mime type + xdg-mime query default <mime type> + # Looks up mime type of file + xdg-mime query filetype <file> + ## Setting defaults Easiest to do with `mimeopen` (from `perl-file-mimeinfo` on Arch): |