11/06/2016

Ubuntu : .SH Scrip Stirng and Variable

Ubuntu : .SH Scrip Stirng and Variable
ตัวอย่าง Run .sh ใน Ubuntu การต่อ Sting ระว่างตัวแปรและ String
  1. D_01_S1="01-ฝข.1";
  2. D_01_SS2="01-งขต.1";
  3.  
  4. snapfile=snap.$D_01_S1.$DayOfWeek
  5. cp snap.$D_01_S1 $snapfile
  6. tar --listed-incremental=$snapfile -cpzf DataCenter_$Days.inc.5.Department.01-ฝข.1.tar.gz $department/$D_01_S1
  7. mv DataCenter_$Days.inc.5.Department.01-ฝข.1.tar.gz /BACKUP/BackupToQnap/ &
  8.  
  9. snapfile=snap.$D_01_SS2.$DayOfWeek
  10. cp snap.$D_01_SS2 $snapfile
  11. tar --listed-incremental=$snapfile -cpzf DataCenter_$Days.inc.5.Department.01-งขต.1.tar.gz $department/$D_01_SS2
  12. mv DataCenter_$Days.inc.5.Department.01-งขต.1.tar.gz /BACKUP/BackupToQnap/ &
  13.  
  14. #### For String ##########
  15.  
  16. snapfile=snap.00-Public.$DayOfWeek
  17. cp snap.00-Public $snapfile
  18. tar --listed-incremental=$snapfile -cpzf DataCenter_$Days.inc.5.Department.00-Public.tar.gz $department"/00-Public"
  19. mv DataCenter_$Days.inc.5.Department.00-Public.tar.gz /BACKUP/BackupToQnap/ &
  20.  
  21. snapfile=snap.01-งสข.$DayOfWeek
  22. cp snap.01-งสข $snapfile
  23. tar --listed-incremental=$snapfile -cpzf DataCenter_$Days.inc.5.Department.01-งสข.tar.gz $department"/01-งสข"
  24. mv DataCenter_$Days.inc.5.Department.01-งสข.tar.gz /BACKUP/BackupToQnap/  &
  25.  
  26.  


File Example ที่เครื่อง Datacenter
  1. nano /DATA/backup-inc.sh

No comments:

Post a Comment