[CentOS] bash script reading directory with while and do
m.roth at 5-cent.us
m.roth at 5-cent.us
Wed May 28 13:35:17 UTC 2014
Elias Persson wrote:
> On 2014-05-25 12:08, Paolo De Michele wrote:> !/bin/bash
> >
> > while read line;
> > do
> > read NR PATH NAME<<<$(IFS=" "; echo $line)
> >
> > cd /var/www/clients/
> > cp -R $PATH /backup/temp/www/
> > cd /backup/temp/www/
> >
> > tar cfz `date +%F`_$NAME.tar.gz web$NR/
> > mv *.tar.gz /backup/www/test/
> > rm -rf /backup/temp/www/*
> >
> > done < sites.txt
>
Dumb question: why not
while read line;
do
read NR PATH NAME<<<$(IFS=" "; echo $line)
cd /var/www/clients/
tar -czf /backup/www/test/`date +%F`_$NAME.tar.gz web$NR/
done < sites.txt
> A few things:
<snip>
> 3. Your `tar` stanza is wrong (if it's not obvious to you why that is,
> now is a good time to make a habit of using long options
> (e.g. `--gzip`) whenever possible).
Why long?
<snip>
mark
More information about the CentOS
mailing list