Cheatsheet
Here are some more or less ordered snippets for things I regularly re-search. Use Control+F to search for keywords or use the listing for quick access.
Fish
Modify file without temp files
You can modify a file in-place (more or less) without using temporary files and manually copy pasting or renaming file by using process substitution...which is using temporary files under the hood anyway lol. Useful for when the command doesn't expect the input file to also be the output file resulting in errors or data loss. Heres an example that formats a json file 'in-place'. Just make sure that the substituted command doesn't fail otherwise you will still lose the file contents since the cat of the empty temp file will still succeed.
cat (cat tests.json | jq | psub) > tests.json
Nvim
Format file in place
Let's say you would want to format a file in-place without temp files. Instead
of doing it on the commandline with process substitution, you could do it in
vim/neovim like this (this example uses jq to format json):
:%!jq
Or with xq for xml:
:%!xq
Copy file name
Copies file name of current buffer
:let @*=expand("%")
POSIX Commands
You can research a single command by looking at the conformance chapter from the OpenGroup spec
(convenience link 2024 POSIX) (just CTRL+F).
Original source (Wikipedia). List taken from https://upload.wikimedia.org/wikipedia/commons/b/b7/POSIX_Utilities.pdf
(List does not include commands that have to do with the SCCS suite of commands)
| Command name | Function |
|---|---|
| alias | define or display aliases |
| ar | create and maintain library archives |
| asa | interpret carriage-control characters |
| at | execute commands at a later time |
| awk | pattern scanning and processing language |
| basename | return non-directory portion of a pathname |
| batch | schedule commands to be executed in a batch queue |
| bc | arbitrary-precision arithmetic language |
| bg | run jobs in the background |
| c17 | compile standard C programs |
| cal | print a calendar |
| cat | concatenate and print files |
| cd | change the working directory |
| cflow | generate a C-language flowgraph (DEVELOPMENT) |
| chgrp | change the file group ownership |
| chmod | change the file modes |
| chown | change the file ownership |
| cksum | write file checksums and sizes |
| cmp | compare two files |
| comm | select or reject lines common to two files |
| command | execute a simple command |
| compress | compress and decompress data |
| cp | copy files |
| crontab | schedule periodic background work |
| csplit | split files based on context |
| ctags | create a tags file (DEVELOPMENT, FORTRAN) |
| cut | cut out selected fields of each line of a file |
| cxref | generate a C-language program cross-reference table (DEVELOPMENT) |
| date | write the date and time |
| dd | convert and copy a file |
| df | report free disk space |
| diff | compare two files |
| dirname | return the directory portion of a pathname |
| du | estimate file space usage |
| echo | write arguments to standard output |
| ed | edit text |
| env | set the environment for command invocation |
| ex | text editor |
| expand | convert tabs to spaces |
| expr | evaluate arguments as an expression |
| false | return false value |
| fc | process the command history list |
| fg | run jobs in the foreground |
| file | determine file type |
| find | find files |
| fold | filter for folding lines |
| fuser | list process IDs of all processes that are using one or more |
| named | files |
| gencat | generate a formatted message catalog |
| getconf | get configuration values |
| getopts | parse utility options |
| gettext | retrieve text string from messages object |
| grep | search a file for a pattern |
| hash | remember or report utility locations |
| head | copy the first part of files |
| iconv | codeset conversion |
| id | return user identity |
| ipcrm | remove an XSI message queue, semaphore set, or shared memory |
| segment | identifier |
| ipcs | report XSI interprocess communication facilities status |
| jobs | display status of jobs in the current shell execution environment |
| join | relational database operator |
| kill | terminate or signal processes |
| lex | generate programs for lexical tasks (DEVELOPMENT) |
| link | call link function |
| ln | link files |
| locale | get locale-specific information |
| localedef | define locale environment |
| logger | log messages |
| logname | return the user's login name |
| lp | send files to a printer |
| ls | list directory contents |
| m | 4 macro processor |
| mailx | process messages |
| make | maintain, update, and regenerate groups of programs (DEVELOPMENT) |
| man | display system documentation |
| mesg | permit or deny messages |
| mkdir | make directories |
| mkfifo | make FIFO special files |
| more | display files on a page-by-page basis |
| msgfmt | create messages objects from portable messages object |
| source | files |
| mv | move files |
| newgrp | change to a new group |
| ngettext | retrieve text string from messages object |
| nice | invoke a utility with an altered nice value |
| nl | line numbering filter |
| nm | write the name list of an object file (DEVELOPMENT) |
| nohup | invoke a utility immune to hangups |
| od | dump files in various formats |
| paste | merge corresponding or subsequent lines of files |
| patch | apply changes to files |
| pathchk | check pathnames |
| pax | portable archive interchange |
| pr | print files |
| printf | write formatted output |
| ps | report process status |
| pwd | return working directory name |
| read | read from standard input into shell variables |
| readlink | display the contents of a symbolic link |
| realpath | resolve a pathname |
| renice | set nice values of running processes |
| rm | remove directory entries |
| rmdir | remove directories |
| sed | stream editor |
| sh | shell, the standard command language interpreter |
| sleep | suspend execution for an interval |
| sort | sort, merge, or sequence check text files |
| split | split a file into pieces |
| strings | find printable strings in files |
| strip | remove unnecessary information from executable files (DEVELOPMENT) |
| stty | set the options for a terminal |
| tabs | set terminal tabs |
| tail | copy the last part of a file |
| talk | talk to another user |
| tee | duplicate standard input |
| test | evaluate expression |
| time | time a simple command |
| timeout | execute a utility with a time limit |
| touch | change file access and modification times |
| tput | change terminal characteristics |
| tr | translate characters |
| true | return true value |
| tsort | topological sort |
| tty | return user's terminal name |
| type | write a description of command type |
| ulimit | report or set resource limits |
| umask | get or set the file mode creation mask |
| unalias | remove alias definitions |
| uname | return system name |
| uncompress | compress and decompress data |
| unexpand | convert spaces to tabs |
| uniq | report or filter out repeated lines in a file |
| unlink | call the unlink function |
| uucp | system-to-system copy |
| uudecode | decode a binary file |
| uuencode | encode a binary file |
| uustat | uucp status enquiry and job control |
| uux | remote command execution |
| vi | screen-oriented (visual) display editor |
| wait | await process completion |
| wc | word, line, and byte or character count |
| who | display who is on the system |
| write | write to another user |
| xargs | construct argument lists and invoke utility |
| xgettext | extract gettext call strings from C-language source files (DEVELOPMENT) |
| yacc | yet another compiler compiler (DEVELOPMENT) |
| zcat | compress and decompress data |