Shell Script Question# Unix - 噫吁兮,危乎高哉
j*n
1 楼
I have multiple *.out files in the current directory.
>ls *.out
a.out b.out c.out
I can use the following command to get the file counts:
>ls -l *.out | wc -l
3
And then I want to allocate the file name to an array as the
following;
file[1]=a.out
file[2]=b.out
file[3]=c.out
Does ls has the function to list first, second, third,
...etc file and then I can use a loop to accomplish this?
Like
while [[ file_count -le file_number ]] #in this case, file
number is 3
do
file[file_count]=`ls *.out ??
>ls *.out
a.out b.out c.out
I can use the following command to get the file counts:
>ls -l *.out | wc -l
3
And then I want to allocate the file name to an array as the
following;
file[1]=a.out
file[2]=b.out
file[3]=c.out
Does ls has the function to list first, second, third,
...etc file and then I can use a loop to accomplish this?
Like
while [[ file_count -le file_number ]] #in this case, file
number is 3
do
file[file_count]=`ls *.out ??