About shell scripting when value too great for base (Error token is "08")

Source: Internet
Author: User

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")

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.