- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- How to list the files in a directory ignoring the ...
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
Discussions
Discussions
Forums
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
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
тАО10-29-2007 07:18 PM
тАО10-29-2007 07:18 PM
I want to list down all the files ina directory but by ignoring the case (Capital or Small letters) of the filename.
Ex - if 2 files are there
Makefile
makefile
Make2
i want to give some thing like
ls | grep -i "M*"
to list down all the files starting with "M".
Can any one Please help me to acieve the same.
thanks and advance
Vikram
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 07:27 PM
тАО10-29-2007 07:27 PM
Re: How to list the files in a directory ignoring the cases of filenames
find . -type f
Ignores directories and such.
man find
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 07:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 07:38 PM
тАО10-29-2007 07:38 PM
Re: How to list the files in a directory ignoring the cases of filenames
>Ex - if 2 files are there: Makefile makefile Make2
>i want to give something like: ls | grep -i "M*"
>to list down all the files starting with "M".
To list all files starting with "M" you can use:
$ ls [Mm]*
You could use grep too:
$ ls | grep -i "^M"
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 08:56 PM
тАО10-29-2007 08:56 PM
Re: How to list the files in a directory ignoring the cases of filenames
$ ls [mM]*
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 11:38 PM
тАО10-29-2007 11:38 PM
Re: How to list the files in a directory ignoring the cases of filenames
Thnk you very much for the answers
ls | grep '[mM]*\.txt'
is working for me
but one problem is if i have files as below
ABCDxxxxMakefile.txt
ABCDyyymakefile.txt
if i give
ls | grep '^ABCD*[mM]*\.txt'
it is not listing the above files.
Please correct the errors in my regular expressions.
Basically the * (Ex- ls | grep '*[mM]*')at the beginning of the string is not working.
thanks and regards
Vikram
- Tags:
- regex
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 11:55 PM
тАО10-29-2007 11:55 PM
Re: How to list the files in a directory ignoring the cases of filenames
You need:
# ls | grep '^ABCD.*[mM]*\.txt'
...to list the files. The dot (".") specifies any character and the asterisk ("*") following says zero or more of the any character.
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-29-2007 11:59 PM
тАО10-29-2007 11:59 PM
Re: How to list the files in a directory ignoring the cases of filenames
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2007 01:12 AM
тАО10-30-2007 01:12 AM
Re: How to list the files in a directory ignoring the cases of filenames
what about
ls -d *[mM]*
mfG Peter
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-30-2007 12:38 PM
тАО10-30-2007 12:38 PM
Re: How to list the files in a directory ignoring the cases of filenames
>Basically the * (Ex- ls | grep '*[mM]*') at the beginning of the string is not working.
As JRF and spex said, you need to use ".*" for "*", "." for "?". You also may need to anchor your RE at the beginning with "^" or end with "$".
Note: you don't need the ".*" at the end or beginning of your RE if it isn't anchored.
The former is a regular expression. The latter is a Pattern Matching Notation.
See regexp(5).
If our answers are helpful, please read and assign points:
http://forums1.itrc.hp.com/service/forums/helptips.do?#33
And if finished, close the thread.
- Tags:
- regex