2011-02-21 54 views
0

我需要把所有文件名目录中的Bash - 如何检索目录的所有名称文件?

例子(PHP)

$filenames = array(); 

foreach($filenames as $filename) 
{ 
    Execute('sh testname.sh $filename'); 
} 

1)如何获得$文件名数组?

2)如何在批处理中转换此项?

+2

你使用什么操作系统? – gor

+0

“批次”或“bash”? “名称”不需要撇号。 –

回答

2
#!/bin/sh 

for file in * 
do 
    sh "$file" 
done 
0

这也应该这样做 - 使用PHP。你可以指定你想要的文件类型,通过搞乱*部分

$files = glob("/tmp/*"); 

foreach($files as $file) { 

    echo "{$file}\n"; 

} 
相关问题