Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

[b]rm ? abc*.dat delete files and ignore case sensitivity.[/b]

Status
Not open for further replies.

alphaaa

Technical User
Jan 15, 2002
45
US
I am trying to write a one line command, which delete files
and ignoring the case sensitivity. For example, I have three files and they can be upper or lower case and I want to delete them all.
xyz045.dat
abc002.dat
ABC003.dat
abc056.dat
I need to delete only abc's files it does not matter what case they arrive. (no grep)

Thanks
Alphaa
 
rm [AaBbCc]*

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Thanks for replying that quick, and it works.

Alphaa
 
This suppose to work, but somehow it is not working when using not default directory. For example;

rm $mydirectory/tmp/[AaBbCc]*.dat
getting the following error
rm: $mydirectory/tmp/[AaBbCc]*.dat non-existent
 
Is the variable mydirectory properly initialised ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
It is initialized properly. In fact I used the absolute path and it is not working as well.
 
And are the [AaBbCc]*.dat files still in $mydirectory/tmp ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Actually, it is working with using *, but unfortunately I can not use [AaBbCc]*.dat since, It will delete all the files and I need to delete individual file like;
rm $mydirectory/tmp/[AaBbCc]002.dat
rm $mydirectory/tmp/[AaBbCc]056.dat


 
what shell are you using?

whatever shell you're using search the 'man' pages of this shell for 'File Name Generation'.

From 'man ksh':

* Matches any string, including the null string.

? Matches any single character.

[...] Matches any one of the enclosed characters. A pair
of characters separated by - matches any character
lexically between the pair, inclusive. If the
first character following the opening "[ " is a "!
", then any character not enclosed is matched. A
- can be included in the character set by putting
it as the first or last character.

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Perhaps try...
[tt]
rm $mydirectory/tmp/[Aa][Bb][Cc]002.dat
rm $mydirectory/tmp/[Aa][Bb][Cc]056.dat
[/tt]
 
I need to delete individual file|/i]
rm [highlight]-i[/highlight] $mydirectory/tmp/[AaBbCc]*.dat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
I need to delete individual file
rm [highlight]-i[/highlight] $mydirectory/tmp/[AaBbCc]*.dat

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Thanks Everyone who help me.
Problem has been resolved by using
rm $mydirectory/tmp/[Aa][Bb][Cc]002.dat to delete indivdual file. (interective mode was not possible to use large quantity of files)
Thanks Ygor
 
Another starting point:
for f in 002 056
do rm $mydirectory/tmp/[Aa][Bb][Cc]$f.dat
done

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top