Saturday, March 10, 2012

What is the command for listing all files ending in small letters in linux/unix?

Suppose there are files like aA, aa, aB, ab.

What is the command for listing all files ending in small letters (aa,ab) in linux/unix?What is the command for listing all files ending in small letters in linux/unix?
You asked a more complicated question than you think. Linux used to have a default language which would allow you to do this easily. If you read any of the manuals you would come to the conclusion this command will work:



ls *[a-z][a-z]



but you'll find on most linux distro's it doesn't. This is because of the LANG environment variable. the default language for most distro's now is utc-8 which means the order of the alphabet is aAbBcC... etc. as opposed to the original (and the linux documentation) which orders it as ABCD... abcd... allowing you to pick them out case easily. So in the above command a-z is going to include all uppercase letters except for 'Z'.



So the first thing we need to do is change your language to something more common (I would suggest setting this up so it is your default) from there our commands will work.



# export LANG=C

# ls *[a-z][a-z]



this will show all files in the current directory with the last 2 characters being lowercase letters. if you want to also search inside the directories and show the full path you can use this command: (again make sure you are using the correct language first)



# find . -name "*[a-z][a-z]"



To set this up as your default language use you can just do this (if your shell is bash):



# echo "export LANG=C" %26gt;%26gt; ~/.bashrcWhat is the command for listing all files ending in small letters in linux/unix?
Do you mean a filename like -%26gt; filename.aa or something like filenameaa.whatever?



You could try a:



sudo find / -name *.aa



sudo find / -name *.aA



or



sudo find / -name *aa.*



If you know the directory you are looking at narrow the seach down by changing find / to something like find /etc.



Hope this helps. Give me more detail if this is not what you are trying to do.What is the command for listing all files ending in small letters in linux/unix?
Hope the source link will help you to find the answer,it consists of all the linux/unix commands..
Go to any Linux forums for questions on Linux, here is a list of Linux forums

http://www.google.com/search?client=ubun鈥?/a>
  • california academy of sciences
  • virtual earth
  • No comments:

    Post a Comment