- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: remove file
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-26-2002 01:01 AM
11-26-2002 01:01 AM
eg.
$ ls
a1 a2 a3 a4 a5
a6 ab a8 a9 a10
a1b a2b
if I run ??? rm a* ??? , then all files will be removed , how can I omit to remove a2 & a6 and the file name ended with ???b???? Thx.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:08 AM
11-26-2002 01:08 AM
Re: remove file
rm -i a*
Then just answer y to the files you wish to remove.
This way will be 100 times quicker than trying to find some kind of pattern match.
Kind regards,
Robert Thorneycroft
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:09 AM
11-26-2002 01:09 AM
Re: remove file
# rm -i
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:19 AM
11-26-2002 01:19 AM
Solutionuse the shell built-in echo command to see what the shell expands your wildcards (i.e. meta characters) to.
Maybe this is not quite what you want, but remember that you can exclude certain character sets with the '!'
e.g.
echo a[!26]*
However in your case a more subtle parsing is required, where I would use commands that can handle regular expressions (e.g. grep, sed, awk, perl)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:28 AM
11-26-2002 01:28 AM
Re: remove file
One method you can use when you want to do something with a large number of files (not necessary removing them) is to list to a file and use a text editor to process the file. Then you can use this file as input to a script. Example:
ls a* >tmpfile
vi tmpfile
while read file
do
#do something
done
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:39 AM
11-26-2002 01:39 AM
Re: remove file
#/bin/sh
for index in `ls a* |grep -v "a[26]"`
do
echo "== removing $index =="
rm -rf $index
done
-Niraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:41 AM
11-26-2002 01:41 AM
Re: remove file
command :
rm a1 a[3-5] a[8-10]
omit to remove a2 - a6 - a1b and a2b
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:47 AM
11-26-2002 01:47 AM
Re: remove file
egrep (or grep -E) with multiple patterns could do it.
rm -i $(ls a* | egrep -v 'a2|a6|b$')
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 01:47 AM
11-26-2002 01:47 AM
Re: remove file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-26-2002 02:14 AM
11-26-2002 02:14 AM
Re: remove file
the correct command is :
rm a1 a[3-5] a[8-9] a10
excuse me for the error