On Tuesday 27,December,2011 09:51 PM, Tony Baldwin wrote:
On Tue, Dec 27, 2011 at 09:11:45PM +0800, lina wrote:
On Tuesday 27,December,2011 08:57 PM, lina wrote:
Hi,
I have two questions, wish to get advice,
Question 1:
For a series of files:
cat a_*.o* | grep "WARNING"
some file like a_1.o12 has WARNING, but others does not have WARNING
How can I let grep returns the filename?
I wrote a very-low-level and not-work-as-expected one,
#!/bin/sh
for filename in *.o*
do
#echo $filename
a= cat $filename | grep "WARNING"
if [ a ]
then
echo $filename
fi
done
for filename in *.o*; do
if [ grep "WARNING" ];
then echo $filename
fi
done
Thanks,
$ ./return_error_filename.sh
./return_error_filename.sh: line 6: [: grep: unary operator expected
$ cat return_error_filename.sh
#!/bin/sh
for filename in *.o*
do
if [ grep "WARNING" ];
then
echo $filename
fi
done
./tony
--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/4ef9d1ce.2000...@gmail.com