Goal :
In this post we will learn use of cat command.When you focus on big data, it also becomes essential to learn some other languages. shell script is the one ,which you are going to use often.
1. To see the content of File :
you can use below command to see the content of file :
cat <nameofyourfile>
Example :
I have file named as data.csv ,and i want to see the full content of that file . use below command
cat data.csv
In below screenshot you can see the complete data (including headers) is visible.
This command is useful when you are putting the file in to hive and want to make sure that file is properly formatted and it is in expected format.
2. To see the content of File Partially :
you can use below command to see the content of file but only required lines:
For that you need to mention grep command , and the keyword which you are searching.
For example i have data of my orders and i want to see only the “laptop” orders , then in that case you can use command like below. here laptop is the keyword which i am searching.
cat orders_data.csv | grep laptop
3. To Combine multiple Files :
you can combine multiple files into one file using below command
cat orders_data1.csv orders_data2.csv orders_data3.csv > new_file.csv
In above command i have combine content of all three files into one new_file.csv.
4. To see Content of Multiple files :
To see content of multiple files use below command:
cat orders_data1.csv orders_data2.csv orders_data3.csv
5. Other options
There are many other options available which you can get with below command: –
cat --help