Cat stands for concatenate.
Case 1.
When the text files has more blank lines, we want to remove them.
We can use Regex \s+ ' \ n '.
Cat File.txt | TR \s ' \ n '
Cat-t file.txt # Show Tabs as ^.
Cat-n file.txt # Show line numbers
. Specifies current directory and. Specifies the parent directory. This convention is followed throughout the Unix file system.
find . -iname "*.txt"
I means ignore the case.
Find. \ (-name "*.txt"-o-name "*.pdf" \)-print
./text.pdf
./new.txt
Find. -iregex ". *\ (\.py\|\.sh\) $"
./test.py
./new. PY
Find. ! -name "*.txt"-print
Files not end with. txt.
Find. -maxdepth 1-type F-print
Just show file and not traverse the sub folder.
Find. -type D
Just Show the Directory
Type:
F:file
D:directory
L:link
Print all the files that were accessed within the last 7 days as follows:
$ find. -type f-atime-7-print
Atime:access time
Mtiem:modify time
-ctime:change time
n order to print all the files that is have access time older than seven minutes, use the
Following command:
$ find. -type F-amin +7-print
For example, find all the files that is have a modification time greater than that the
Modification time of a given file.txtfile as follows:
$ find. -type F-newer File.txt-print
Search based on file size
Based on the file sizes of the files, a search can be performed as follows:
$ find. -type f-size +2k
# Files have a size greater than 2 kilobytes
Instead of Kwe can use different size units as the following:
b–512 byte blocks
C–bytes
W–two byte words
K–kilobyte
M–megabyte
G–gigabyte
Find. -type f-name "*.C"-exec cat {} \; >all_c_files.txt
$ cat Example.txt # example file
1 2 3 4 5 6
7 8 9 10
11 12
$ Cat Example.txt | Xargs
1 2 3 4 5 6 7 8 9 10 11 12
$ Cat Example.txt | Xargs-n 3
1 2 3
4 5 6
7 8 9
10 11 12
echo "Hello Linux" | Tr ' A-Z ' A-Z
HELLO LINUX
echo "Hello 123 World 456" | TR- D ' 0-9 '
Hello World
echo Hello 1 char 2 next 4 | TR -d-c ' 0-9 \ n '
1 2 4
echo "I am your friends?" | Tr-s "
I am your friends?
Find-type F | Xargs md5sum
e8bc686b2c380b9ad56c024a03384150./sub/java.txt
a5bf231497e5d503172bfd39a387b197./all_txt_files.txt
e827b6437257f24b9e5fbba44fd98f5c./num.txt
B6d9275e7e16b154059677fac91baa79./test.txt
B6d9275e7e16b154059677fac91baa79./mul_bank.txt
sort -r:sort in reverse order
split can used to split file to specify size.
Linux Shell Basic2 Cat Find TR