Mailinglist Archive: opensuse (3135 mails)

< Previous Next >
Re: [opensuse] filtering
  • From: Vince Oliver <vince@xxxxxxxxxxxxxxx>
  • Date: Sat, 10 Mar 2007 09:05:21 +0100 (CET)
  • Message-id: <Pine.LNX.4.62.0703100859300.7868@xxxxxxxxxxxxxx>


On Fri, 9 Mar 2007, Randall R Schulz wrote:

On Friday 09 March 2007 16:07, Randall R Schulz wrote:
Vince,

On Friday 09 March 2007 15:37, Vince Oliver wrote:
Hi All,

I should take all "more*.dat" files from each "DH*"
directory and to write out first 5 rows into "list" fajl. So each
"DH*" directory should have "list" falj with 5 rows from all
"more*.dat" within it. This command line works this job


for dir in DH* ; do
  for file in `find $dir -type f -name "more*data.dat" -print`; do
    awk 'BEGIN{FS=","}{if(NR>1 && NR<7){
    f=n=FILENAME;sub(/[^/]+$/,"list",f);sub(/.*\//,"",n);print
    $6,$7,n>>f}}' $file
  done
done


But I want would NOT like to have file names in "list" that contain
words "t10" or "t9". How to filter them out in this context?

The grep family of commands can return only the status of the search,
so you could add these arguments to your find command before the
-print argument:

  -exec egrep -vq '\<t(9|10)\>' \;

Woops! Make that:

   -exec egrep -vq '\<t(9|10)\>' {} \;


When you say "... contain words ..." I assume you mean you only want
to exclude files where t9 and t10 occur as separate words, but not
exclude files that contain, say, "last9" or "test10". If that is not
what you want, remove the \< and \> word boundary signifiers from the
egrep pattern above.

thanks for reply
I have files like

something_t1_something.dat
something_t2_something.dat
something_t3_something.dat
.....
something_t10_something.dat

I would nor like to have files with t9 and t10 appears in the fileName


Did you mean like this? It does not work but may be I did not understand where to include egrep

for dir in DH* ; do
for file in `find $dir -type f -name "less*data.dat" -exec egrep -vq '\<tau(9|10)\>' {} \; -print`; do
awk 'BEGIN{FS=","}{if(NR>1 && NR<7){ f=n=FILENAME;sub(/[^/]+$/,"list",f);sub(/.*\//,"",n);print $6,$7,n>>f}}' $file
done
done








Randall Schulz
--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx


--
To unsubscribe, e-mail: opensuse+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: opensuse+help@xxxxxxxxxxxx

< Previous Next >
Follow Ups