Skip to main content

Reading Files

View File from Bottom​

tac filename.txt

Concatenate Multiple Files​

cat file1.txt file2.txt

Number lines in cat​

cat -n list.txt

View File with less from end​

less +G list.txt

View File from end and tail​

less +F app.log

Start less from first instance of string 'fail'​

less +/fail app.log

Find a file​

locate $FILENAME

less with Line Numbers​

less -N $FILE

Find Largest Files in Directory​

sudo du -h --max-depth=1 /var/log/program

Recursive Read First and Last Lines from File​

find . -name "*log*" | while read -r file; do echo $file; head -n 1 $file; tail -n 1 $file; done;

Creating Files​

touch {config,main}.py