chmod 777 /目录/ -R
参数-R是对该目录及子目录的所有文件授权。
shell
linux 循环
http://www.linuxdiyf.com/viewarticle.php?id=206569
字符串拼接和截取
http://www.linuxdiyf.com/linux/9890.html
字符拼接例子:
#!/bin/sh
#============ get the file name ===========
#aws s3 cp ./mongoDataOutput/ s3://weibo200g/mongoData
#echo -e "请输入你要读取的文件夹路径\n当前路径为${PWD}"
InputDir=./mongoDataOutput
#echo "你输入的文件夹路径为${InputDir}"
#echo -e "请输入你要将数据输出保存的文件路径\n当前路径为${PWD}"
OutputFile='s3://weibo200g/'
#echo "输出保存的文件路径为${OutputFile}"
#: > $OutputFile #清空OutputFile
#循环读取文件夹名
for file_a in ${InputDir}/*; do
temp_file=`basename $file_a`
#echo ${temp_file}
#echo ${file_a}
#echo ${OutputFile}${temp_file}
aws s3 cp ${file_a} ${OutputFile}${temp_file}
#echo aws s3 cp ${file_a} ${OutputFile}${temp_file}
done
读取文件夹所有文件名字例子:
#!/bin/sh
#============ get the file name ===========
echo -e "请输入你要读取的文件夹路径\n当前路径为${PWD}"
read InputDir
echo "你输入的文件夹路径为${InputDir}"
echo -e "请输入你要将数据输出保存的文件路径n当前路径为${PWD}"
read OutputFile
echo "输出保存的文件路径为${OutputFile}"
: > $OutputFile #清空OutputFile
#循环读取文件夹名
for file_a in ${InputDir}/*; do
temp_file=`basename $file_a`
echo $temp_file >> $OutputFile
done
basename
basename a/b/c.txt ==>> c.txt
basename a/b/c.txt ==>> c