KandZ – Tuts

We like to help…!

Linux CLI 45 🐧patch and tr commands

a - patch command
patch command is used to apply a diff file to an original source
It is useful for applying bug fixes, and updating software source
syntax β†’ patch [options] original-file patch-file
common options: -b β†’ makes a backup file
-c β†’ interpret the patch file as a ordinary context diff -f β†’ force
We create one file and another one that is different
diff -u config_v1.ini config_v2.ini config_patch.diff β†’ creates a patch file
patch config_v1.ini config_patch.diff β†’ apply the patch to the file

b - tr command
tr command is used to delete or translate characters
It reads from standard input and writes to standard output
It performs characters replacements according to a mapping defined by the first argument
syntax β†’ tr [options] SET1
echo "hello" | tr 'e' 'E' β†’ changes e to E
echo "hello world" | tr 'lo' 'LO' β†’ changes lo to LO
echo "hello world" | tr -d 'lo' β†’ deletes lo
echo "HELLO WORLD" | tr 'A-Z' 'a-z' β†’ changes all capital letters to small

Leave a Reply