Question: Given file.tsv, use bash (Shell) to find the rows that contain either 'hello' or 'hi' and do not contain 'USA'. The final output should contain

Given file.tsv, use bash (Shell) to find the rows that contain either 'hello' or 'hi' and do not contain 'USA'. The final output should contain line numbers that meet this criteria. What is wrong with either of my codes to answer this question:

grep -nE ^((?!USA).)*\t(hi|hello)\t file.tsv

grep -n hi\|hello file.tsv | grep -v Comedy file.tsv | cut -d : -f 1

The file has a lot of rows and columns and the output we need here is line numbers that meet the criteria

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!