Bash

Search and Filter data of a file using command line

cut -d';' -f1 some_data.csv
Instead of the whole file, it prints only the first column of the some_data.csv file. The field separator (aka delimiter) between the columns is a semicolon (;).


cut -d'-' -f1,5,12,13 some_data.csv
Prints the first, fifth, twelfth and thirteenth columns of the some_data.csv file. The delimiter is a dash (-).


grep "something" some_data.csv
Returns all the lines in the some_data.csv file that contain the "something" string. (It's case sensitive by default.)


grep -v "something" some_data.csv
Returns all the lines in the some_data.csv file that do not contain the "something" string. (It's case sensitive by default.)


grep -i "Something" some_data.csv
Returns all the lines in the some_data.csv file that contain the "Something" string. It's not case sensitive.