3
rated 0 times
[
3]
[
0]
/ answers: 1 / hits: 938
/ 2 Years ago, tue, may 3, 2022, 11:24:25
I have the following three files
**file_01.sh**
GOOD_word
bla bla BAD_word
miao GOOD_word bau
BAD_word
GOOD_word foo
**file_02.sh**
GOOD_word yes
GOOD_word bla bla BAD_word
GOOD_word bla
BAD_word
**file_03.sh**
just BAD_word
and bla bla
I would like to have the following result:
**“o_file.txt”:**
./i_dir/file_01.sh:1:GOOD_word
./i_dir/file_01.sh:3:miao GOOD_word bau
./i_dir/file_01.sh:5:GOOD_word foo
./i_dir/file_02.sh:1:GOOD_word yes
./i_dir/file_02.sh:3:GOOD_word bla
This is what I try so far, but does not work.
find ./dir -type f -exec grep -E -i -H "GOOD_word" {} ; |
grep -v “BAD_word” {} ; >> o_file.txt;
More From » command-line