Skip to content

Basic commands

Created on Dec 4, ’22 ・ Updated on Mar 5, ’23

sort, uniq, cut

# Sort the first column of <file> in numerical reverse order (-k1gr) and then
# the third column alphabetically, using ':' as field separator.
cat <file> | sort -t':' -k1gr -k2d

grep, sed, awk

  • In-place file modification: sed -i -E 's/^(SELINUX=).*$/\1disabled/' /etc/sysconfig/selinux

Archives

  • zip -r <zip file> <file>...
  • tar -xzf bar.tar.gz -C <dest>

Misc

  • scp -P <port> <source> <target>, e.g. user@host:path
  • mktemp [-d] /tmp/file_XXXX, create files or directory with unique names
  • setxkbmap -model apple\_laptop -layout ch -variant fr\_mac -option lv3:ralt\_switch