bash-tutorial/tutorial/display_files.org

1.0 KiB

Display files

Show content of a file. Concatenates and writes file. Using "tac" reverses the result of "cat" command

cat file.txt

Using head, tail and less to show parts of files

Showing the first two entries

 head -n 2 /etc/hosts
127.0.0.1 localhost
127.0.1.1 myuser

Showing the last two entries

tail -n 2 /etc/hosts
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
less /etc/hosts
127.0.0.1 localhost
127.0.1.1 myuser
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Show content of a zip file using less and pipe "|"

unzip -l tntvillage_484094.zip | less