Re: bash script reading directory with while and do

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



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

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos




[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux