Bash 的有些语言习惯太奇怪了,可能是同时又需要考虑到程序、用户的交互,所以设计起来有很多的限制。
参考手册
http://www.gnu.org/software/bash/manual/bashref.html
高级Bash脚本编程指南
http://www.linuxpk.com/doc/abs/
http://www.linuxsir.org/main/doc/abs/abs3.7cnhtm/index.html
- bash 有没有 readline 这个功能?
Zixia Music Download
# This is a download script
# Download music form Zixia.net using the links in the playalbum.m3u
# You should download it form zixia.net by hand(recommend firefox)
# First write by ppip@2007.11.6
echo -e "Script Start Here\n-----------------\nThe origin file\n-----------------"
cat playalbum.m3u
echo -e "-----------------\nConvert Code\n-----------------"
iconv -f gbk -t utf8 -o play.lst playalbum.m3u
cat play.lst
echo -e "-----------------\nGet off the comment\n-----------------"
cat play.lst | grep "^http" > play.lst
cat play.lst
echo -e "-----------------\nMake dir\n-----------------"
mkdir -p "`head -n 1 play.lst | cut -d '/' -f7,8 | sed -e s/%20/\ /g`"
echo -e "-----------------\nDownload the music\n-----------------"
for x in `cat play.lst`
do
echo -e "-----------------\nNow downloading: $x\n-----------------"
wget -O "`echo $x | cut -d '/' -f7,8,9 | sed -e s/%20/\ /g | sed -r 's/\r//'`" `echo $x | sed -r 's/\r//'`
done
echo -e "-----------------\nClean Up\n-----------------"
mv "`head -n 1 play.lst | cut -d '/' -f7 | sed -e s/%20/\ /g`/" "音乐/"
rm playalbum.m3u
rm play.lst
echo -e "-----------------\nOK, job down\n-----------------\nScript End Here"
# Download music form Zixia.net using the links in the playalbum.m3u
# You should download it form zixia.net by hand(recommend firefox)
# First write by ppip@2007.11.6
echo -e "Script Start Here\n-----------------\nThe origin file\n-----------------"
cat playalbum.m3u
echo -e "-----------------\nConvert Code\n-----------------"
iconv -f gbk -t utf8 -o play.lst playalbum.m3u
cat play.lst
echo -e "-----------------\nGet off the comment\n-----------------"
cat play.lst | grep "^http" > play.lst
cat play.lst
echo -e "-----------------\nMake dir\n-----------------"
mkdir -p "`head -n 1 play.lst | cut -d '/' -f7,8 | sed -e s/%20/\ /g`"
echo -e "-----------------\nDownload the music\n-----------------"
for x in `cat play.lst`
do
echo -e "-----------------\nNow downloading: $x\n-----------------"
wget -O "`echo $x | cut -d '/' -f7,8,9 | sed -e s/%20/\ /g | sed -r 's/\r//'`" `echo $x | sed -r 's/\r//'`
done
echo -e "-----------------\nClean Up\n-----------------"
mv "`head -n 1 play.lst | cut -d '/' -f7 | sed -e s/%20/\ /g`/" "音乐/"
rm playalbum.m3u
rm play.lst
echo -e "-----------------\nOK, job down\n-----------------\nScript End Here"
