using recursion in bash script
I need to write a script that preforms an operation on all files in a directory and it's sub-directories. How does one go about doing this in bash? Also, what's the best way to distinguish between a file and a folder?
thanks! ...aaron |
use find:
to run "dosomething file" on all the files: Code:
find . -type f -exec dosomething ’{}’ \; |
This is how it works:
Code:
#! /bin/bash Code:
find /some/directory | while read NAME |
Thanks! a mixture of both worked perfectly for me:
Code:
... thanks! ...aaron **edit** I'm going to start a new topic since so the information will be easier to find if other people have the same question. |
Quote:
Code:
find $DIR -type f -exec sed -i 's/'$IN_TXT'/'$OUT_TXT'/g' '{}' \; |
All times are GMT -5. The time now is 10:38 PM. |