fileset='APP11.txt APP12.txt SPACEDB11.txt WEB11.txt WEB12.txt'
Hi there,
Give the fileset, if I can use grep to find all the files.
How do I show:
All Servers:
instead of
APP11.txt:
APP12.txt:
SPACEDB11.txt:
WEB11.txt:
WEB12.txt:
fileset='APP11.txt APP12.txt SPACEDB11.txt WEB11.txt WEB12.txt'
Hi there,
Give the fileset, if I can use grep to find all the files.
How do I show:
All Servers:
instead of
APP11.txt:
APP12.txt:
SPACEDB11.txt:
WEB11.txt:
WEB12.txt:
If your grep supports the -h option, you could try:
grep -h "something" file*
or if your grep does not know this option, try:
cat file* | grep "something"
You could also use a utility that does not show the file names:
awk '/something/' file*
sed -n '/something/p' file*
Do you want to explicitly show All servers: if a grep ped string exists in all text files mentioned?
Yes to Rudi Question.
Try
awk '
BEGIN {for (i=2; i<ARGC; i++) T[ARGV]++}
$0 ~ SP {delete T[FILENAME]}
END {P = 1
for (t in T) P = 0
if (P) print "All servers: "}
' SP="Hello" $fileset
Maybe something like this?
for x in a b c; do echo somestring > $x ;done # for testing
[ `grep -l somestring a b c | wc -l` -eq `ls a b c | wc -l` ] && echo 'All'
All
Try:
awk '
FNR==1{
A[f=FILENAME]
}
$0~s{
F[f]
}
END {
a=1
for(f in A)
if(!(f in F)) {
a=0
break
}
if(a)
print "All Servers:"
else
for(f in F)
print f ":"
}
' s=foo file*