Gentoo Archives: gentoo-user

From: wraeth <wraeth@×××××××××.au>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] bash script question
Date: Mon, 18 Aug 2014 09:43:15
Message-Id: 1408354973.1863.1.camel@wraeth.id.au
In Reply to: [gentoo-user] bash script question by Adam Carter
1 On Mon, 2014-08-18 at 18:54 +1000, Adam Carter wrote:
2 > But this matches if grep fails both times as well as when it matches both
3 > time. Any ideas?
4
5 If you don't mind using a quick loop, you could use something like:
6
7 n=0
8 for f in file1.txt file2.txt file3.txt file4.txt; do
9 grep 'string' ${f} >> /dev/null && n=$[n+1]
10 done
11
12 if [[ $n == 4 ]]; then
13 do_something
14 fi
15
16
17 --
18 wraeth <wraeth@×××××××××.au>

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] bash script question Stroller <stroller@××××××××××××××××××.uk>