On Saturday 10 March 2007 00: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?
I wouldn't use heavy tools like awk for something as simple as this for dir in DH*; do for file in `find $dir -type f -name more\*.dat`; do ( [ ${file/t10/} != $file ] || [ ${file/t9/} != $file ] ) || head -5 $file
$dir/list; done; done
I'm not very happy with the string tests, but I couldn't find a bash function that returned true on substring match. If anyone can think of a cleaner way of doing it, I'd love to know it -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org For additional commands, e-mail: opensuse+help@opensuse.org