- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: finding and removing a file that ends in .<num...
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
06-10-2005 07:52 AM
06-10-2005 07:52 AM
I would like to search for and delete files ending in a *.
For example test.3457, test.1233
find / -name 'test.*' -exec rm -f {} \;
would take out all files with test.* including files such as test.dontdelete for example. I want to restrict this to only .
Any script I can use for this kind of task available or can find do this somehow?
Thanks!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 07:55 AM
06-10-2005 07:55 AM
Re: finding and removing a file that ends in .<number>
This will list the files so you can be sure you want to remove them.
find / -name "*.[0-9]" -print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 08:03 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 08:03 AM
06-10-2005 08:03 AM
Re: finding and removing a file that ends in .<number>
The files you are wanting, do they all end in 4 digits? In which case,
find / -name "*.[0-9][0-9][0-9][0-9]" -print
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 08:05 AM
06-10-2005 08:05 AM
Re: finding and removing a file that ends in .<number>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2005 08:24 AM
06-10-2005 08:24 AM
Re: finding and removing a file that ends in .<number>
Clay, Rick thanks a lot.
Both worked and as you suggested Rick, Clays hits it on the spot!!
THANKS!!! and such prompt response too!!!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 07:40 AM
06-12-2005 07:40 AM
Re: finding and removing a file that ends in .<number>
WRONG: !!!!
find . -type f -name 'test.*' | grep -E -e '.*\.[0-9]*$' | while read FNAME
do
echo "${FNAME}"
# rm ${FNAME}
done
RIGHT:
find . -type f -name 'test.*' | grep -E -e '.*\.[0-9]+$' | while read FNAME
do
echo "${FNAME}"
# rm ${FNAME}
done
Note the change from '*' to '+' -- not that I'm nit-picky.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 04:35 PM
06-12-2005 04:35 PM
Re: finding and removing a file that ends in .<number>
find / -name "test.[0-9]*" | xargs rm -f
-exec rm -f {} will make problem when file count is increased. You can use xargs to avoid that.
hth.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-12-2005 05:08 PM
06-12-2005 05:08 PM
Re: finding and removing a file that ends in .<number>
find .
This will accumulate all the file names and will call 'rm -f' only once at the end. Same as xargs. However if the command line goes beyond a limit size, find would break it into multiple commands and execute them intelligently.
-Amit