I have 2
files in Linux
like below
file1
test_1
test_3
test_5
test_6
file2
test_1,smoke_test
test_2,rain_test
test_3,sun_test
test_4,wind_test
I want to compare these two files and delete the tables in file1
that are present in file2
that is the first part before comma(,)
Output required:
file3
test_5
test_6
I have tried like below
grep -v -Ff <(cut -d',' -f1 file2) file1 >file3
I got what I want.
Now when I write a script It throws an error
new.sh: line 67: syntax error near unexpected token `('
Script
#!/bin/bash
grep -v -Ff <(cut -d',' -f1 file2) file1 >file3
I'm running it with:
sh -x script.sh