[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: which is the best command to use



On Tue, 27 Dec 2011 14:20:02 +0100, lina scribbled:

> 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
> 
> Please give me some advice,
> 
> Best regards,
> 
> 
>>
>> Question 2:
>>
>> ls . | xargs -i -t cp ./{} {}.bak
>>
>> How does xargs work,
>>
>> I checked google, :
>> -i : replace the string
>> -t print
>> but still lack well understanding,
>>
>> how those xargs organise things,
>>
>> and
>> $ ls .
>> a.txt b.txt
>>
>> above will give a.txt.bak b.txt.bak
>> ls | xargs -i cp ./{} {basename {}.bak} definitely not work,
>>
>>
>> Sorry I send it to debian list, I asked on another bash list, for two
>> days the second question, no one replied. I have much more faith in
>> this list.
>>
>> WIth all the best regards,

whoops, my bad (so focused on the -l)
its
	$ grep -l "WARNING" *.o*

:(



-- 
>@<
Bill Dennen			ieee1014@hotmail.com
Of all the things I've lost, I miss my mind the most ...


Reply to: