Welcome to Linux Forums!

With a comprehensive Linux Forum, information on various types of Linux software and many Linux Reviews articles, we have all the knowledge you need a click away, or accessible via our knowledgeable members.

Linux Forum ArticlesLinux ForumsLinux Forum DownloadsLinux Hosts
Home|Register|FAQ|Member List|Calendar|Unanswered Posts|Forum Rules|Today's Posts|Advanced Search|
SEARCH FOR IN
Go Back   Linux Forums > GNU Linux Zone > Linux Newbie
Reload this Page List all files starting with an uppercase..
Linux Forums
Linux Forums
Welcome To The Linux Forums!
Welcome to Linux Forums. We pride ourselves in being one of the largest Linux communities on the web, we encourage you to REGISTER on our forums and participate in the community. There are over 150,000 members ready to answer your questions. JOINING US today will allow you to make new posts, get support, send messages to other members and submit downloads to our downloads directory and many other great features!

Linux Newbie If you're new to the wonderful world of Linux, start here!

Reply
 
Thread Tools Display Modes
Old 07-04-2008   #1 (permalink)
djfog
Just Joined!
 
Join Date: Jun 2008
Posts: 25
List all files starting with an uppercase..

Hi to all.Well I have come up with this command
Code:
ls -a|grep '^[A-Z]'
but it is also lists the directories.I'm looking for a command to list inly files.
Thanks in advance..
djfog is offline   Reply With Quote
Old 07-04-2008   #2 (permalink)
GNU-Fan
Linux Newbie
 
Join Date: Mar 2008
Posts: 143
find * -maxdepth 0 -type f | grep '^[A-Z]'

'f' stands for 'file'.
There is also a built in regex evaluator in find so you won't have necessarily to grep.
GNU-Fan is offline   Reply With Quote
Old 07-04-2008   #3 (permalink)
nalg0rath
Linux User
 
nalg0rath's Avatar
 
Join Date: Sep 2004
Location: Stockholm
Posts: 303
Send a message via AIM to nalg0rath Send a message via MSN to nalg0rath
Code:
# ls -ap|grep '^[A-Z].*[^/]$'
ls -p puts a / on the end of all directories that are listed. Regexp brakedown:
Code:
^[A-Z] -- line that begins with uppercase character
. -- any character
* -- the . any number of times
[^/]$ -- exclude lines with / right before end of line
Not tested but I think it would do the job.
__________________
Dívide Et Ímpera
nalg0rath is offline   Reply With Quote
Old 07-04-2008   #4 (permalink)
djfog
Just Joined!
 
Join Date: Jun 2008
Posts: 25
Thank you both for your answers.Both commands work great.
djfog is offline   Reply With Quote
Old 07-04-2008   #5 (permalink)
djfog
Just Joined!
 
Join Date: Jun 2008
Posts: 25
Well,another question now is how to list all the files that were created a specific month.I tried something similar,but it didn't work.Here is the code:
Code:
read -p "give the month in 2 digit number" month
echo "the number of files created on $month is:"
ls -ap|grep '\-\'$month'\-[^/]$'|wc -l
Any ideas how to fix it..?
djfog is offline   Reply With Quote
Old 07-04-2008   #6 (permalink)
djfog
Just Joined!
 
Join Date: Jun 2008
Posts: 25
After trial and error I found that this command does the job:
Code:
ls -l|grep '\-\'$month'\-'|grep -v ^d|wc -l
Thanks for your advices.You've been very helpful.
djfog is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT. The time now is 05:37 AM.




© 2000 - 2008 - All Rights Reserved - Property of  MAS Media

Content Relevant URLs by vBSEO 3.0.0