Lessons · Terminal · cat: print it to the screen
Reading a file
cat prints a whole file. Given two files it prints one after the other, which is where its name, concatenate, comes from.
Hone is a place to practise programming. This is one of its lessons, written out in full and free to read without an account.
What it is for
The quickest look inside a config, a log or a script. For a long file, head and tail show a piece instead of scrolling for a minute.
How to think about it
cat for short files, head and tail for long ones, less when you want to scroll and search.
Worked example
printf 'one\ntwo\n' > a.txtA two-line file.
printf 'three\n' > b.txtA one-line file.
cat a.txtone, two.
cat a.txt b.txtone, two, three: both files, in order.
Your turn
Print settings.ini to the screen.
settings.ini
Try it at a real prompt
The trap
cat on a huge log floods the screen for a minute. tail -n 20 shows the end, which is usually what you wanted.
Practise cat: print it to the screen on HoneA question on it now, a coding challenge where there is one, and it is remembered for review. Free, no email needed.