I saw a shell problem today, just to practice practicing
You need to create subdirectories (named in years) in multiple directories (such as Beijing Shanghai Tianjin Guangzhou, and so on), then enter subdirectories, create new directories, and name them on the day.
The ultimate effect is this:
Copy Code code as follows:
china/guangdong/
china/guangdong/shenzhen/2010/1206
china/guangdong/shenzhen/2010/1207
china/guangdong/shenzhen/baoan/2010/1206
china/guangdong/shenzhen/baoan/2010/1207
china/guangdong/shenzhen/baoan/guangming/2010/1206
china/guangdong/shenzhen/baoan/guangming/2010/1207
My implementation:
#!/bin/bash
read-p "Please input country:" Cou
read-p "Please input City:" City
read-p ", please input name:" name
#echo "$cou, $city, $name"
date=$ (date +%y)
#echo $date
date2=$ (date +%m%d)
# echo $date 2
If [-d]./$cou/$city/$name/$date/$date 2 "];then
echo" The dir is exit
else
mkdir-p./$ cou/$city/$name/$date/$date 2
fi
Effect:
[Root@localhost hbshell]# test.sh
Please input Country:china
Please input City:hangzhou
Please input NAME:HB
#[root@localhost hbshell]# ll china/hangzhou/hb/2011/0321/
Total 0