Results 1 to 6 of 6
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 ...
- 07-04-2008 #1Just 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
but it is also lists the directories.I'm looking for a command to list inly files.Code:ls -a|grep '^[A-Z]'
Thanks in advance..
- 07-04-2008 #2
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.
- 07-04-2008 #3ls -p puts a / on the end of all directories that are listed. Regexp brakedown:Code:
# ls -ap|grep '^[A-Z].*[^/]$'
Not tested but I think it would do the job.Code:^[A-Z] -- line that begins with uppercase character . -- any character * -- the . any number of times [^/]$ -- exclude lines with / right before end of line
- 07-04-2008 #4Just Joined!
- Join Date
- Jun 2008
- Posts
- 25
Thank you both for your answers.Both commands work great.
- 07-04-2008 #5Just 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:
Any ideas how to fix it..?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
- 07-04-2008 #6Just Joined!
- Join Date
- Jun 2008
- Posts
- 25
After trial and error I found that this command does the job:
Thanks for your advices.You've been very helpful.Code:ls -l|grep '\-\'$month'\-'|grep -v ^d|wc -l


Reply With Quote