A problem was encountered today when writing a timed CP script, value too great for base (Error token is "08")
The number system that originally started with 0 is recognized by default as an octal number, so my $datem-1 gets the month of the month in return: value too great for base (Error token is "08") This error, the solution is
The $datem format or the declaration is called decimal, ' 10# $datem '-1 so it can. That is, the variable or number that will be converted to decimal is preceded by a ' 10# ':
Give me the code:
[email protected] shell]# VI backwebdb.sh #!/bin/bash#admin Fengtaotao Email:23956580@qq. Com#fri Jul3 -: *: -Cst -Pathh=/web/www/morp/musicfile/PATHD=/opt2/musicfile/Datem= ' Date +%m 'if["$datem"== on]; then Datem="_12"Datey= ' Date +%Y ' Datey=$ ($datey-1))ElseDatem="$ ((10# $datem-1))"# Datey= ' Date +%Y ' echo $datemfiecho $datey #echo $datem #dird="$datey $datem"#readd= ' Date +%N '. Txt#find $pathh-name $dird &>>$readd # forIinch$ (cat $readd); Do# AAC=$ (echo $i | awk-f"/" '{print $6 "/" $7 "/"}') # AAC=${pathd}${aac}# CP-R $i $aac &>>Dbcp.log#done#rm-RF $readd
OK, so the problem is solved.
Then there will be no re-execution of the backup, because I use Find in this script to obtain information on the system resource consumption is relatively large, of course, if you need to back up the directory is not changed, you can directly read a path document
Can be less on the system consumption!
About shell scripting when value too great for base (Error token is "08")