Command to display first few and last few lines of a file
I have a file with many rows, and each row has a timestamp at the starting, like
I have a file with many rows, and each row has a timestamp at the starting, like
I was working through a tutorial and saw use of both cat myfile.txt and cat < myfile.txt. Is there a difference between these two sequences of commands? It seems both print the contents of a file to the shell.
A lot of command-line utilities can take their input either from a pipe or as a filename argument. For long shell scripts, I find starting the chain off with a cat makes it more readable, especially if the first command would need multi-line arguments.
When handling log files, some end up as gzipped files thanks to logrotate and others not. So when you try something like this:
I’d like to know if there is a way that I could cat file like php.ini and remove all lines starting with ;
Sometimes when I cat a binary file by mistake, my terminal gets garbled up. Nothing a quick reset can’t fix, but couldn’t an attacker theoretically create a file that, when displayed on a terminal, would execute some arbitrary code? Through an exploit in the terminal emulator or otherwise.
Are these two commands any different on how they go about zero-ing out files? Is the latter a shorter way of doing the former? What is happening behind the scenes?