Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
10-03-2011, 04:19 PM
|
#1
|
|
Member
Registered: Oct 2011
Posts: 45
Rep: 
|
File names listing question
I'm learning how to filenames, for instance, all file names starting with 'a', is echo [a]*
All names starting with a and containing three characters, I deduced was [echo]??
All names starting with 'a' but ending with a non a character is echo [a]* | echo *[b-z]
I figured that out but here is where it get's tricky for me, how would one list all filenames that begin with 'a' but not 'aa'?
Then how would one go about creating a file named 'result' that has all the filenames that begin with 'a' but no consecutive 'a'?
Any help would be appreciated!
|
|
|
|
10-03-2011, 04:25 PM
|
#2
|
|
Senior Member
Registered: Aug 2009
Posts: 3,497
|
Sounds a bit like homework, try 'man bash' then '/Pattern Matching' 'n' to get to the Pattern Matching section.
|
|
|
|
10-03-2011, 05:04 PM
|
#3
|
|
Member
Registered: Oct 2011
Posts: 45
Original Poster
Rep: 
|
I've read that but when i try for instance,
echo [^aa]* it returns,
faa gaaa hah iaia jja
Then when I try and pipe, such as,
echo [a]* | echo [^aa]* is outputs the same as above, which is not what I'm looking for since there are other files such as a, etc..
|
|
|
|
10-03-2011, 05:24 PM
|
#4
|
|
Senior Member
Registered: Aug 2009
Posts: 3,497
|
Quote:
|
how would one list all filenames that begin with 'a' but not 'aa'?
|
Within the '[]', '^' means not. So the command above means "' starting with an a' followed by ' not an a' followed by ' anything'"
|
|
|
1 members found this post helpful.
|
10-03-2011, 07:36 PM
|
#5
|
|
Member
Registered: Oct 2011
Posts: 45
Original Poster
Rep: 
|
Ah! For some reason I assumed I had to use pipe, as I'm sure you notice, this is all new to me, but interesting at the same time, thanks!!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 01:54 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|