zesttec / Linux-knowledgebase

0 stars 0 forks source link

Command line #2

Open zesttec opened 4 years ago

zesttec commented 4 years ago

Table of contents generated with markdown-toc

ls

ls -a: list all files including hidden files. ls -l or ls -la: list all files and their permission info, etc. ls -lh display the size in a human-readable way

grep

grep -r "xxx" .: search string "xxx" under current directory.

Redirection

Redirection (link)

redirect the output to a file: SomeCommand > SomeFile.txt Or if you want to append data: SomeCommand >> SomeFile.txt If you want stderr as well use this: SomeCommand &> SomeFile.txt or this to append: SomeCommand &>> SomeFile.txt
if you want to have both stderr and output displayed on the console and in a file use this: SomeCommand 2>&1 | tee SomeFile.txt (If you want the output only, drop the 2 above)

mkdir

mkdir -p aa/bb/cc '-p' guarantees the dirs along the path can be created if it doesn't exist. Without '-p', if you use "mkdir aa/bb/cc" while there is not aa dir or bb dir, an error would be posted and cc dir can not be created.

Ref: https://www.runoob.com/linux/linux-comm-mkdir.html