Data Analysts/Scientists should have a basic knowledge of Unix Commands, the goal of this post is to give some examples of how the shell commands would help them on their daily tasks. For the first examples we will consider the following eg1.csv:
ID,Name,Dept,Gender
1,George,DS,M
2,Billy,DS,M
3,Nick,IT,M
4,George,IT,M
5,Nikki,HR,F
6,Claudia,HR,F
7,Maria,Sales,F
8,Jimmy,Sales,M
9,Jane,Marketing,F
10,George,DS,M
**Q: **How to print the first or the last 3 rows of the files.
## The first
head -n 3 eg1.csv
## The last
tail -n 3 eg1.csv
**Q: **How to skip the first line(s) or the last line(s).
Sometimes we want to skip the first line which usually is the headers. The command is:
## it skips the first line
tail -n +2 eg1.csv
## it skips the last 4 lines
head -n -4 eg1.csv
## skip first line
1,George,DS,M
2,Billy,DS,M
3,Nick,IT,M
4,George,IT,M
5,Nikki,HR,F
6,Claudia,HR,F
7,Maria,Sales,F
8,Jimmy,Sales,M
9,Jane,Marketing,F
10,George,DS,M
#data-science #bash #ai #shell #unix