tags:

views:

27

answers:

1

Hi there, I have a directory with roughly 100000 files in it, and I want to perform some function on all files beginning with a specified string, which may match tens of thousands of files.

I have tried

ls mystring*

but this returns with the bash error 'Too many arguments'. My next plan was to use

find ./mystring* -type f

but this has the same issue.

The code needs to look something like

for FILE in `find ./mystring* -type f`
do
    #Some function on the file
done

Thanks in advance, Rik

+2  A: 

use

find . -name 'mystring*'
Sergei Tulentsev
Thanks very much
RikSaunderson
and to execute some function "find . -name 'mystring*' -exec [command]" for example delete "find . -name 'mystring*' -exec rm {} \;"
eldar
Where {} is a placeholder for file name :-) (so you can construct your own actions)
Sergei Tulentsev