Linux system commands - operating files

Linux system commands

which: View the location of the command
which cd
find: View the location of the file

find starting path-name "File name to find"

find starting path-size +|- n [k|M|G]

find / -name test.txt

Find files larger than 100k

find / -size +100K
grep: Filter keywords from files

grep [-n] keyword file path

-n: Optional, indicating the line number of the matching line displayed in the results

grep "demo" test.txt

Use the pipe character "|", the following means: filter the position of the demo character from the test.txt file, the pipe character means: use the content on the left as the input on the right

cat test.txt | grep "demo"
wctotal

wc [-c -m -l -w] file path

option meaning
-c Count the number of bytes
-m Count the number of characters
-l Count rows
-w Count the number of words
wc test.txt
echoOutput the specified content on the command line

echo output content

echo "hello Linux"

Use "`" to output in command form

echo `pwd`

Use the ">" redirection method to overwrite and write, as follows: write hello to the test.txt file

echo "hello" > test.txt

Use the ">>" redirection method to append writing, as follows: append hello to the test.txt file

echo "hello" >> test.txt
tailView file tail information

tail [-f -num] Linux path

option meaning
-f Keep track of
-num Count the number of characters

Continue to track the tail content of the file. If there are changes, the status will be updated. Click ctrl+c to exit the program.

tail -f test.txt

Guess you like

Origin blog.csdn.net/cleverstronge/article/details/130943630