I want to use an if/then that tests for the existence of a string in 4
files. Usually I do this by checking the exit code of grep, when i'm
checking a single file. However, I cant get the syntax right for multiple
checks.
To troubleshoot I’ve dropped back to just checking two files, and i’ve
On Mon, 2014-08-18 at 18:54 +1000, Adam Carter wrote:
But this matches if grep fails both times as well as when it matches both
time. Any ideas?
If you don't mind using a quick loop, you could use something like:
n=0
for f in file1.txt file2.txt file3.txt file4.txt; do
grep 'string' ${f}
On Mon, 18 August 2014, at 10:42 am, wraeth wra...@wraeth.id.au wrote:
On Mon, 2014-08-18 at 18:54 +1000, Adam Carter wrote:
But this matches if grep fails both times as well as when it matches both
time. Any ideas?
If you don't mind using a quick loop, you could use something like:
n=0
On Mon, 2014-08-18 at 12:29 +0100, Stroller wrote:
On Mon, 18 August 2014, at 10:42 am, wraeth wra...@wraeth.id.au wrote:
I propose addressing this with an array of the filenames.
Thus additional files can be added for testing, without manual adjustment of
the expected total.
+1
I
On 18/08/2014 12:29, Stroller wrote:
On Mon, 18 August 2014, at 10:42 am, wraeth wra...@wraeth.id.au wrote:
On Mon, 2014-08-18 at 18:54 +1000, Adam Carter wrote:
But this matches if grep fails both times as well as when it matches both
time. Any ideas?
If you don't mind using a quick loop,
On Mon, 18 August 2014, at 12:58 pm, wraeth wra...@wraeth.id.au wrote:
... I've never been
overly familiar with bash arrays (I tend towards python or perl if I
need anything even starting to get complex);
Indeed, I had to look up the syntax from my own snippets folder, myself.
I need to
On Mon, 18 August 2014, at 1:16 pm, Kerin Millar kerfra...@fastmail.co.uk
wrote:
...
(( count += matches ))
done (grep -hcm1 -F $string ${files[*]})
Oh, this is lovely.
I've learned some things today.
if (( count == ${#files[@]} )); then
May I ask why you prefer these
On 18/08/2014 15:02, Stroller wrote:
On Mon, 18 August 2014, at 1:16 pm, Kerin Millar kerfra...@fastmail.co.uk
wrote:
...
(( count += matches ))
done (grep -hcm1 -F $string ${files[*]})
Oh, this is lovely.
I've learned some things today.
if (( count == ${#files[@]} ));
On 18/08/2014 15:18, Kerin Millar wrote:
On 18/08/2014 15:02, Stroller wrote:
On Mon, 18 August 2014, at 1:16 pm, Kerin Millar
kerfra...@fastmail.co.uk wrote:
...
(( count += matches ))
done (grep -hcm1 -F $string ${files[*]})
Oh, this is lovely.
I've learned some things
Hi 4 everyone,
I have a little problem:
i have a file list in /tmp/iadmos (contains 28 file name which are in the
current directory, i made this list with:
egrep -il 'trt_attr.*[,]iadm' t*.dcl /tmp/iadmos
then I want to cut out the files which don't contain the string 'NOIADM'.
So I did:
then I want to cut out the files which don't contain the string 'NOIADM'.
So I did:
for i in `cat /tmp/iadmos` ; do egrep -lv 'NOIADM' $i ; done
which gave me all 28 file name. I wondered about it, so I tried:
for i in `cat /tmp/iadmos` ; do egrep -l 'NOIADM' $i ; done
which gave
11 matches
Mail list logo