Jinx
08-15-2003, 01:44 AM
Gday,
I am currently working on a Bash script to du -h a directory, pipe it to a file and then iterate through the file and send it to an SQL database...
It looks something as follows:
<code>
for i in $mydirectory1 $mydirectory2 $mydirectory3;
do
du -h >> afile;
done
</code>
Now after I have piped it to a file I want to pass it to a Mysql Database, but I can't simply do something like "cat afile |awk 'print{1}' "... cause this will list all the data in that column (the size) in the one row, rather than row by row...
Does anyone have any ideas how I can itterate through that file and add the values to MySql?
The MySql table has three columns... size, path_name and date.
Cya round
Jinx
I am currently working on a Bash script to du -h a directory, pipe it to a file and then iterate through the file and send it to an SQL database...
It looks something as follows:
<code>
for i in $mydirectory1 $mydirectory2 $mydirectory3;
do
du -h >> afile;
done
</code>
Now after I have piped it to a file I want to pass it to a Mysql Database, but I can't simply do something like "cat afile |awk 'print{1}' "... cause this will list all the data in that column (the size) in the one row, rather than row by row...
Does anyone have any ideas how I can itterate through that file and add the values to MySql?
The MySql table has three columns... size, path_name and date.
Cya round
Jinx