I am trying to recurse into folders and then run commands on them, using bash script. Any suggestions?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you want to recurse into directories, executing a command on each file found in those, I would use the
findcommand, instead of writing anything using shell-script, I think.That command can receive lots of parameters, like
typeto filter the types of files returned, orexecto execute a command on each result.For instance, to find directories that are under the one I’m currently in :
Which will get me somehthing like :
Same to find the files under the current directory :
which will get me something like this :
Some would say “it’s not shell”… But why re-invent the wheel ?
(And, in a way, it is shell ^^ )
For more informations, you can take a look at :
man find