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