Hi,
I have a text file and I want to delete all rows that contain a particular string of characters. How do I go about doing that? Thanks!
Hi,
I have a text file and I want to delete all rows that contain a particular string of characters. How do I go about doing that? Thanks!
Try:
awk '!/your_string/' file
Hi.
Perhaps with grep -v
The awk code does not really work, because I want to delete the whole row that contains the specific string, not just that particular string and column.
Did you try it? It should delete whole row...
Yes, I did try. It only deleted the column that contains the string and not the first column.
Maybe post your sample input and desired output.
Sample input:
rs4648831 rs4648831 0 1.000 2.14305
rs4648831 rs4648832 3010 0.951 2.14844
rs2840525 WARNING Query snp not in Release 22
rs2840525 WARNING No matching proxy snps found
rs2843130 rs2843130 0 1.000 2.14363
rs2843130 rs2254895 931 1.000 2.14094
Desired output:
rs4648831 rs4648831 0 1.000 2.14305
rs4648831 rs4648832 3010 0.951 2.14844
rs2843130 rs2843130 0 1.000 2.14363
rs2843130 rs2254895 931 1.000 2.14094
All the lines that contain WARNING are deleted.
[root@linux ~]# cat in
rs4648831 rs4648831 0 1.000 2.14305
rs4648831 rs4648832 3010 0.951 2.14844
rs2840525 WARNING Query snp not in Release 22
rs2840525 WARNING No matching proxy snps found
rs2843130 rs2843130 0 1.000 2.14363
rs2843130 rs2254895 931 1.000 2.14094
[root@linux ~]# awk '!/WARNING/' in
rs4648831 rs4648831 0 1.000 2.14305
rs4648831 rs4648832 3010 0.951 2.14844
rs2843130 rs2843130 0 1.000 2.14363
rs2843130 rs2254895 931 1.000 2.14094
grep -v "WARNING" file