Operating System - HP-UX
1826333 Members
3375 Online
109692 Solutions
New Discussion

Supplying find command with multiple filenames

 
SOLVED
Go to solution
Danny Fang
Frequent Advisor

Supplying find command with multiple filenames

HI,

I'm attempting to do a dos2unix for several files with different pattern names, all of which are located in different directory locations.

I need to do a dos2unix on the following file types on a HPUX-11:
i) *.sh
ii) *.csh
iii)*.perf
iv) checkcomp*

I could do a for loop, and supply the for loop with the filenames listed in (i) - (iv), if they are all located in the same directory. However, it's not the case here.

How do I supply multiple filenames as arguments into the find command ?

Thanks
Danny.
4 REPLIES 4
Dennis Handly
Acclaimed Contributor

Re: Supplying find command with multiple filenames

>following file types on a HP-UX-11:
1) *.sh
2) *.csh
3) *.perf
4) checkcomp*

find path1 path2 \( -name "*.sh" -o -name "*.csh" -o -name "*.perf" \
-o -name "checkcomp*" \) ...
Eric SAUBIGNAC
Honored Contributor
Solution

Re: Supplying find command with multiple filenames

Bonjour,

Following Denis's answer, something like :

find path1 path2 -type f \( -name "*.sh" -o -name "*.csh" -o -name "*.perf" -o -name "checkcomp*" \) | while read FILE
do
echo "Working on $FILE ... \c"
cp -p "$FILE" "$FILE".old
dos2ux $FILE.old > $FILE
echo "terminated"
done

Of course make some tests before applying this

Eric
ManojK_1
Valued Contributor

Re: Supplying find command with multiple filenames

One shot you can do this by the following command if you don't want to preserver the original file.

find . -name '*-M' -o -name '*-D' -o -name '*-C' -exec dos2ux {} \;

Manoj K
Thanks and Regards,
Manoj K
ManojK_1
Valued Contributor

Re: Supplying find command with multiple filenames

One shot you can do this by the following command if you don't want to preserver the original file.

find . -name '*.sh' -o -name '*.csh' -o -name '*.perf' -o -name 'checkcomp'-exec dos2ux {} \;

Manoj K
Thanks and Regards,
Manoj K