10 tr Command Examples in Linux
Tr Command in Linux with Examples
On Unix-like operating systems, the tr command automatically translates substitutes, or maps one set of characters to another. The tr utility copies the standard input to the standard output with substitution or deletion of selected characters. In this form, the characters in the string string1 are translated into the characters in string2 where the first character in string1 is translated into the first character in string2 and so on. If string1 is longer than string2 , the last character found in string2 is duplicated until string1 is exhausted. In this form, the characters in string1 are compressed as described for the -s option see below.
Each single file is compressed into a single file. The compressed file consists of a GNU zip header and deflated data. With no arguments, gzip compresses the standard input and writes the compressed file to standard output. Difference between Gzip and zip command in Unix and when to use which command. This command will create a compressed file of mydoc.
In addition, we will share a few useful examples of removing a file, removing a directory, removing multiple files or directories, prompting for confirmation, removing files recursively and forcing removal of files. The rm command is also one of the frequently used commands on a Linux system, but also a dangerous command that you will discover later on in this article. To remove multiple files at onces, specify the file names one by one for example: file1 file2 or use a pattern to remove multiple files for example: pattern ending with. To remove a directory, you can use the -r or -R switch, which tells rm to delete a directory recursively including its content sub-directories and files.