##########################
## Viewing files (cat, less, more, head, tail, watch)
##########################

# displaying the contents of a file
cat filename

# displaying more files
cat filename1 filename2

# displaying the line numbers
can -n filename

# concatenating 2 files
cat filename1 filename2 > filename3

# viewing a file using less
less filename

# less shortcuts:
# h         => getting help
# q         => quit
# enter     => show next line
# space     => show next screen
# /string   => search forward for a string
# ?string   => search backwards for a string
# n / N     => next/previous appearance


# showing the last 10 lines of a file
tail filename

# showing the last 15 lines of a file
tail -n 15 filename

# showing the last lines of a file starting with line no. 15
tail -n +5 filename

# showing the last 10 lines of the file in real-time
tail -f filename


# showing the first 10 lines of a file
head filename

# showing the first 15 lines of a file
head -n 15 filename

# running repeatedly a command with refresh of 3 seconds
watch -n 3 ls -l