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