Flash Sale: Flat 70% + Addl. 25% Off on all Courses | Use Coupon DS25 in Checkout | Offer Expires In

  Enroll Now

Seeing Inside File - cat, tail, head

To see what is inside a text file, you can use either cat, tail or head command.

Using cat you can see the whole content of the file:

cat myfirstfile_copy.txt

Do not use this command to look inside a huge file. For the huge file, you can use the more command which would display the content of a file in a paginated way:

more myfirstfile_copy.txt

tail shows you the last few lines of a file

tail myfirstfile_copy.txt

By default tail shows you only last 10 lines, you can change it using the command line option. For example, to see the last 20 lines, you can use

tail -20 myfirstfile_copy.txt

Say you want to see the web server's (Apache, Nginx) access log of your website. Logs will keep on getting appended to access.log file when visitors visit your website. Now you can run below command and keep it running. It will keep on printing newly added lines in the access.log.

tail -f access.log

If you are interested in the first few lines, you can use the head command. By default head shows you only first 10 lines, you can change it using the command line option. For example, to see the first 20 lines, you can use

head -20 myfirstfile_copy.txt

No hints are availble for this assesment

Answer is not availble for this assesment

Loading comments...