I have a CSV file looks like this:
id,country
12343,China
23455,Japan
47,Singapore
374,Australia
6572e,United Kingdom
- Firstly I want to count the total number of lines whose column id length is greater than 3
- Next I want to remove the lines whose id length is not equal to 5, and whose id contains an alphabetic character
- Finally I want to create a new file to store the result
I have tried awk method but I get this result:
mylaptop@MacBook-Pro ~ % awk 'length($1)!=19 {c++} END {print c+0}' myfile
quote>
If I type the command like this:
mylaptop@MacBook-Pro ~ % awk 'length($1)!=19 {c++} END {print c+0}' <myfile>
It will show:
zsh: parse error near `\n'
The expected output should be like in the Mac terminal:
mylaptop@MacBook-Pro ~ % awk 'length($1)!=19 {c++} END {print c+0}' myfile
4
and save all the changes in a file.
I am new to linux, so can you show the full commands for 3 questions?
column idthat have more than three characters but then you want to remove the lines where the number if characters is not equal to five. Which one do you want? Add the expected output to your question to clarify this.