- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Supplying find command with 1 txt file containing ...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2008 06:48 AM
11-10-2008 06:48 AM
Supplying find command with 1 txt file containing a list of files to be located
Last week, I posted a question about supplying the find command with multiple file names, in which thanks to the help of the those who responded, yielded the script below.
Thread:
http://forums13.itrc.hp.com/service/forums/questionanswer.do?threadId=1285274
SCRIPT:
find . -depth -type f \( -name "*.sh" -o -name "*.csh" -o -name "*.perf" -o -name "checkComp*" -o -name "waitfor" -o --name "stopcomp" -o -name "*.list" \) | while read file
do
echo "Copying $file ... \c"
cp -p "$file" "$file.ORIG"
dos2unix $file.ORIG > $file
done
echo "Finished converting files to UNIX format ...\c"
However, I'm attempting to list these txt file names into a file, and supply the txt file containing these file names into find and dos2unix.
Since the files are located in different subdirectories within the main directory tree, I attempted this script:
for i in `cat fileList.txt` do
find . -depth -type f name $i -exec dos2unix {} {} \;
done
But I'd want to know how I can supply a text file containing the list of files to undergo a dos2unix operation, through the find (since files are located in different sub-directories)?
Could anyone point out how this can be done?
Thanks
Danny
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2008 07:13 AM
11-10-2008 07:13 AM
Re: Supplying find command with 1 txt file containing a list of files to be located
Since the files are located in different subdirectories within the main directory tree, I attempted this script:
for i in `cat fileList.txt` do
find . -depth -type f name $i -exec dos2unix {} {} \;
done"
================================
A) If you are using the same list of files as the first example, this is going to be extremely wasteful, as you are going execute the "find" once for each "pattern" in your "fileList.txt"....
B) Syntax of the "dos2unix" may be incorrect. The HP-UX command is "dos2ux" and it can't do "in-place" conversions (ie. source and destination file the same.)
C) If you check, you will find that "{}" lists the relative path to the file found from the starting place {".") you specified.
================================
"But I'd want to know how I can supply a text file containing the list of files to undergo a dos2unix operation, through the find (since files are located in different sub-directories)?"
================================
The above is not clear, can you elaborate? I'm not sure how "find / subdirectories" enters into the above (see "C" above
Could anyone point out how this can be done?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2008 07:29 AM
11-10-2008 07:29 AM
Re: Supplying find command with 1 txt file containing a list of files to be located
If you specify an absolute path as the 'find' directory argument, I think you will have what you need:
# find /path -depth ...
...instead of:
# cd /path
# find . -depth ...
You can't supply a text file containing the list of files as an argument to 'find', though.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2008 09:49 AM
11-10-2008 09:49 AM
Re: Supplying find command with 1 txt file containing a list of files to be located
It may be faster to do a find then grep your list of files. I.e. you are searching for a few files in a directory tree with lots of files:
find path -type -f | grep -f fileList.txt | xargs dos2unix_type_script
>JRF: You can't supply a text file containing the list of files as an argument to 'find', though.
Only if you supply the file to a script that builds a find command.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2008 01:47 PM
11-10-2008 01:47 PM
Re: Supplying find command with 1 txt file containing a list of files to be located
having just the leaf names or pattern in your listfile, I suggest to create the corresponding find-pattern in your script:
while read pat
do
findopt=${findopt:+$findopt -o -name $pat}
findopt=${findopt:--name $pat}
done
find . -type f \( $findopt \) |
while read ff
do
...
done
mfG Peter
PS: untested
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-10-2008 02:41 PM
11-10-2008 02:41 PM
Re: Supplying find command with 1 txt file containing a list of files to be located
It looks like it does what you say.