[wellylug] a bit of awk / sh dumping value
E.Chalaron
e.chalaron at xtra.co.nz
Mon Mar 22 17:02:37 NZST 2004
Hello Ewen
> location=`find /home -path '*.doc' | awk --field-separator=/ '{$3}'`
> catdoc "${nom_file}" > "/home/$location/$(basename ${nom_file} .doc).txt"
I eventually figured it out. but without thinking that find will relist all
my files.
Since the all lot is already in
IFS=$(echo -e "\n\r\t")
for nom_file in `find /home -path '*.doc'`;
do
location=`find /home -path '*.doc' | awk --field-separator=/ '{$3}'`
echo $location
catdoc "${nom_file}" > "/home/$location/$(basename ${nom_file} .doc).txt"
done
the second 'find' will relist all the files giving $location the last value.
no good. my mistake.
The ideal would be to dump each value of nom_file into /tmp/file.txt
and rewrite such as :
IFS=$(echo -e "\n\r\t")
for nom_file in `find /home -path '*.doc'`;
do
expression to dump the value of nom_file into a file called /tmp/file.txt
location= awk --field-separator=/ '{$3}' /tmp/file.txt
echo $location #just to make sure
catdoc "${nom_file}" > "/home/$location/$(basename ${nom_file} .doc).txt"
done
Now I should be able to find a way of dumping this value into /tmp/file.txt
not very elegant, but I have no better idea so far.
Thanks
Edouard
> or:
>
> location=$(find /home -path '*.doc' | awk --field-separator=/ '{$3}')
> catdoc "${nom_file}" > "/home/$location/$(basename ${nom_file} .doc).txt"
>
> (which should be equivilent on a POSIX system, although as written
> I think it'll only work on a GNU system due to the long argument style).
>
> Ewen
More information about the wellylug
mailing list