关于script的for语法

2 views
Skip to first unread message

wd

unread,
May 26, 2010, 9:11:48 PM5/26/10
to sh...@googlegroups.com, ubuntu-sg-zh
假设我有music 1.ape 和 music 2.ape
#!/bin/bash

apelist=$(ls | grep ape$)
echo -e $apelist

for apefile in $apelist
do
echo "File is $apefile"
done

然后用这个script来执行
得到的输出结果是
Music 1.ape Music 2.ape
File is Music
File is 1.ape
File is Music
File is 2.ape
我想要得到的结果是

Underground 5.0.ape Underground 6.0.ape
File is Music 1.ape
File is Music 2.ape
请问要怎么写呢?
先谢谢各位了

wd

unread,
May 26, 2010, 9:46:08 PM5/26/10
to sh...@googlegroups.com, ubuntu-sg-zh
真的可以阿 .. 请问下read是 ? 读取apefile变量的意思 ?
感谢


On Thu, 2010-05-27 at 10:07 +0800, vivian huang wrote:
> #!/bin/bash
>
> apelist=$(ls | grep ape$)
> echo -e $apelist
>

> echo "$apelist"| while read apefile


> do
> echo "File is $apefile"
> done
>

> 2010/5/27 wd <wud...@gmail.com>

--
Sign by WD
http://wdstudio.blogbus.com

Reply all
Reply to author
Forward
0 new messages