From the course: Command Line Data Analysis
Cat and less - Unix Tutorial
From the course: Command Line Data Analysis
Cat and less
- [Instructor] In this part of data ingestion, we're going to look at the content of file. We're going to use a command called "cat" and one called "less". So let's say I have a file and I want to view the content. So let's look at monday.txt and I can see what it is. Cat can get more than a single file. So if I'm going to do tree, I'm going to see now the content of these two files. Sometimes I use cat with dash n to show me the line numbers, which is helpful. So data and Monday and now I have a line number for each line. Sometimes the files can be really big, so let's do the Austin CSV, and we see that we have a lot and we need to scroll up and down to see what is the content. Sometimes if you are using some kind of a terminal emulator such as Tmax, this might be an issue. For this, we have another command called less. Less data and then again Austin CV is just going to show you the beginning of the file and you can use the arrows to scroll up and down. You can even use the slash command to look for things. For example, if I look for the 11th, and then it's going to jump me every time I hit n, it's going to move me to the next line containing this term. If I want to quit less, I hit the Q button and we're out. Sometimes we have data which is compressed. For example, we have the, which is in a GZ format. If I'm going to do cat, it's going to show me some gibberish but there is an equivalent zcat which is going to show me the content uncompressed. This is a long file so I'm hitting Control + C to terminate the program. And the same way that we have zcat, we have also bzcat in case the file is compressed with a BZ2 compression.