- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: HP-UX find command unable to remove files from...
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
02-15-2011 07:49 AM
02-15-2011 07:49 AM
I'm writing a ksh script to find and remove files and directories that are multiple levels deep. A typical directory looks somewhat like this
/hpcnfs4/nfsdir/data/PRIVATE_DATA/username/aileron/reduced_spec_test/Pressure read/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure read/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure read/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure read/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure read/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure read/Res_DPA1_H2_Pres_ip/MERGE/OUTPUT/reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/MERGE/OUTPUT/reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/MERGE/OUTPUT/reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/MERGE/OUTPUT\reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/MERGE/OUTPUT\reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/MERGE/OUTPUT\reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/MERGE/OUTPUT\reduced_spec_test/Pressure read/Result_DPA1_H2_Pressure_op/GP7/OUTPUT\
That is right the directory name has back slashes and blank spaces
( /Preasure read/, OUTPUT\).
The current filesystem is mounted on a windows machine, hence the blank spaces and back slashes in the directory name.
I'm writing a script to look for such directories, remove files and them remove the underlying directory.
I have tried using find -exec rm option.. it fails with 'Pathname exceeds system limitations'. Not sure how else I can remove these files and directories.
Thanks all for your valuable responses.
Please note I'm not a perl expert, hence writing a ksh shell script.
Regards
K
Solved! Go to Solution.
- Tags:
- find
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 08:06 AM
02-15-2011 08:06 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
Did you quote the directory name arguments to 'find()'?
For example:
# find "/Pressure read OUTPUT\" -exec ls -ld {} +
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 08:07 AM
02-15-2011 08:07 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
Pete
Pete
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 08:14 AM
02-15-2011 08:14 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
path names in window client machine
You may try the commands like below ,with -xdev option if it works
find / -size +1000c -mtime 100 -type f -exec -xdev rm {} \;
find /path -mtime +30 -type f -exec -xdev rm {} \;
Thanks
Manix
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 08:25 AM
02-15-2011 08:25 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
I'm using
find "$direc" -name "*.*" -type f -exec rm {} \;
Since there are many such directories, I read all the directories in a loop and process each directory. The env variable "$direc" holds the directory information.
Thanks and Regards
K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 08:34 AM
02-15-2011 08:34 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
It might be easier if you supplied only a
failing command (with its output) instead of
a whole script (which can't easily be tested
by others).
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 12:58 PM
02-15-2011 12:58 PM
SolutionI can understand evil spaces but shouldn't the backslashes be converted to slashes for each directory component?
>it fails with 'Pathname exceeds system limitations'.
Is this a Windows error?
You may have to cd into that directory and remove files from that CWD.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 03:44 PM
02-15-2011 03:44 PM
Re: HP-UX find command unable to remove files from directories multiple levels deep
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2011 11:20 PM
02-15-2011 11:20 PM
Re: HP-UX find command unable to remove files from directories multiple levels deep
Thank you all for your replies.
Some background to the problem -
The users use an application that has this inherent feature of creating these recursive directories. Our backups are failing because of these multiple levels of subdirectories. Hence the script to tidy up this, until the problem with the application is fixed.
I'm afraid, I'm not allowed to change the directory naming, hence I have to process backslashes. Since this filesystem is hosted on a HP-UX 11.31 which is then mapped onto windows PCs.
The 'Pathname exceeds system limitations' error message is on the HP-UX machine.
Thanks and Regards
Kaushik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:34 AM
02-16-2011 10:34 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
> The users use an application that has this inherent feature of creating these recursive directories.
Are they really recursive?
I would try adding '! -follow' to your 'find' expression.
> The 'Pathname exceeds system limitations' error message is on the HP-UX machine.
This might be 'find' abandoning searches that are truly recursive. As I said, try preventing the visit of symbolic links with ' ! - follow '.
Also, unless your full path name exceeds the value of 'getconf POSIX_PATH_MAX' characters (which should be 255 characters), you should otherwise be fine.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:41 AM
02-16-2011 10:41 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
Since you have given a "bunny" at this point, suggesting a solution to your problem, what exactly was the solution?
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2011 10:44 AM
02-16-2011 10:44 AM
Re: HP-UX find command unable to remove files from directories multiple levels deep
Thank you all for your valuable comments.
Dennis Handly's suggestion of cd to the directory and remove the files from CWD worked. It was a bit of a workaround, but it worked.
Here is what I have changed in the script.
find "$direc" -type f >> ${REMOVEFILE_LIST}
while read FILE2REMOVE
do
echo "File --- "
echo "$FILE2REMOVE"
echo " "
cd $(dirname "$FILE2REMOVE")
ls -l "$(basename "$FILE2REMOVE")"
rm "$(basename "$FILE2REMOVE")"
ls -l "$(basename "$FILE2REMOVE")"
done < ${REMOVEFILE_LIST}