Hi all,
I would like to print all lines in a file based on conditions on nth field.
Example below: Here I would like to print all lines in which 6th field has (cat or dog or bat or rat)
and does not have (mat or pat).
File:
abc def ghi jkl mno cat_dog_bat_rat
abc def ghi jkl mno cat_dog_bat
abc def ghi jkl mno cat_dog
abc def ghi jkl mno cat
abc def ghi jkl mno cat_dog_bat_rat_mat_pat
abc def ghi jkl mno cat_dog_bat_rat_mat
abc def ghi jkl mno cat_dog_bat_rat_pat
abc def ghi jkl mno cat_dog_bat_rat_vat
Output should be:
abc def ghi jkl mno cat_dog_bat_rat
abc def ghi jkl mno cat_dog_bat
abc def ghi jkl mno cat_dog
abc def ghi jkl mno cat
abc def ghi jkl mno cat_dog_bat_rat_vat
Appreciate is someone can help with grep or sed script for this.
Thanks!
I would like to print all lines in a file based on conditions on nth field.
Example below: Here I would like to print all lines in which 6th field has (cat or dog or bat or rat)
and does not have (mat or pat).
File:
abc def ghi jkl mno cat_dog_bat_rat
abc def ghi jkl mno cat_dog_bat
abc def ghi jkl mno cat_dog
abc def ghi jkl mno cat
abc def ghi jkl mno cat_dog_bat_rat_mat_pat
abc def ghi jkl mno cat_dog_bat_rat_mat
abc def ghi jkl mno cat_dog_bat_rat_pat
abc def ghi jkl mno cat_dog_bat_rat_vat
Output should be:
abc def ghi jkl mno cat_dog_bat_rat
abc def ghi jkl mno cat_dog_bat
abc def ghi jkl mno cat_dog
abc def ghi jkl mno cat
abc def ghi jkl mno cat_dog_bat_rat_vat
Appreciate is someone can help with grep or sed script for this.
Thanks!