开发者

Bash - How to retrieve all names file of a directory?

开发者 https://www.devze.com 2023-02-12 03:43 出处:网络
I need to get all filename in a directory Example (in PHP) $filenames = array(); foreach($filenames a开发者_如何学运维s $filename)

I need to get all filename in a directory

Example (in PHP)

$filenames = array();

foreach($filenames a开发者_如何学运维s $filename)
{
   Execute('sh testname.sh $filename'); 
}

1)How to get $filenames array?

2) How to translate this in Batch?


#!/bin/sh

for file in *
do
  sh "$file"
done


This should do it too - using PHP. You can specify what types of file you want by messing about with the * part

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

foreach($files as $file) {

  echo "{$file}\n";

}
0

精彩评论

暂无评论...
验证码 换一张
取 消