LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 02-05-2010, 10:07 PM   #1
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Rep: Reputation: 0
How to check if filenames are lowers case.


What would be the best way to verify files in a folder are all lower case and if a file is not lower case, output the filename to the screen.
 
Old 02-05-2010, 10:15 PM   #2
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,451

Rep: Reputation: 83
Hya

>ls | grep \[~A-Z\]

Happy Penguins!

edit:
You also need to be specific, all lower case and not lower case are not exclusive. There are many occasions (not lower case) AND (not upper case).

Last edited by kaz2100; 02-05-2010 at 10:18 PM.
 
Old 02-05-2010, 10:26 PM   #3
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kaz2100 View Post
Hya

>ls | grep \[~A-Z\]

Happy Penguins!

edit:
You also need to be specific, all lower case and not lower case are not exclusive. There are many occasions (not lower case) AND (not upper case).
Hey -

Well I have a image folder and in that folder are a bunch of *.gif images.

I want to verify filenames are lowercase, for example 'main.gif' and not 'Main.gif' / 'MAIN.gif' / 'maIN.gof' / etc.

But what you gave me seems to give help too =]
Thanks for your help

Last edited by gqchynaboy; 02-05-2010 at 10:28 PM.
 
Old 02-05-2010, 10:35 PM   #4
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Original Poster
Rep: Reputation: 0
How would I do it for a .HTML file itself now? For example the HTML contains img src="images/lockup.gif" I want to verify all other images are 'some_pretty_pic.gif' and not 'Some_Pretty_Pic.gif' and if it does contain uppercase, output it to the screeen.
 
Old 02-06-2010, 12:12 AM   #5
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,988
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Something like
Code:
grep -E 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"' *html
should work.


Cheers,
Tink
 
Old 02-06-2010, 06:15 AM   #6
kaz2100
Senior Member
 
Registered: Apr 2005
Location: Penguin land, with apple, no gates
Distribution: Debian testing woody(32) sarge etch lenny squeeze(+64) wheezy jessie
Posts: 1,451

Rep: Reputation: 83
Hya,

Be careful anything like _123.gif

Do you what them or not?

Happy Penguins!

P.S. My previous post was incorrect. Should have been 'exclusive or" instead of "exclusive"
 
Old 02-06-2010, 11:19 AM   #7
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by kaz2100 View Post
Hya,

Be careful anything like _123.gif

Do you what them or not?

Happy Penguins!

P.S. My previous post was incorrect. Should have been 'exclusive or" instead of "exclusive"
Having _1234.gif is okay to have in a fielname and
grep -E 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"' *html
seemed to do it's job. Now only thing is that it's hard to read, I would like to only see maybe 'images/02_140_A9_Reg_EM_PRO_r2_08.gif' and not the whole line of HTML code. I assume I need to use the sed command and some how parse it out?

Code:
valign="top" bgcolor="#ffffff" ><img src="images/02_140_A9_Reg_EM_PRO_r2_08.gif" width="35" height="69" border="0" alt=""></td>
 
Old 02-06-2010, 01:47 PM   #8
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,988
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Quote:
Originally Posted by gqchynaboy View Post
Now only thing is that it's hard to read, I would like to only see maybe 'images/02_140_A9_Reg_EM_PRO_r2_08.gif' and not the whole line of HTML code. I assume I need to use the sed command and some how parse it out?

Code:
valign="top" bgcolor="#ffffff" ><img src="images/02_140_A9_Reg_EM_PRO_r2_08.gif" width="35" height="69" border="0" alt=""></td>
Easy enough, no need for sed:
Code:
grep -Eo 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"' *html
In action:
Code:
echo 'valign="top" bgcolor="#ffffff" ><img src="images/02_140_A9_Reg_EM_PRO_r2_08.gif" width="35" height="69" border="0" alt=""></td>'| grep -Eo 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"'
img src="images/02_140_A9_Reg_EM_PRO_r2_08.gif"
Cheers,
Tink
 
Old 02-06-2010, 01:59 PM   #9
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Tinkster View Post
Easy enough, no need for sed:
Code:
grep -Eo 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"' *html
In action:
Code:
echo 'valign="top" bgcolor="#ffffff" ><img src="images/02_140_A9_Reg_EM_PRO_r2_08.gif" width="35" height="69" border="0" alt=""></td>'| grep -Eo 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"'
img src="images/02_140_A9_Reg_EM_PRO_r2_08.gif"
Cheers,
Tink
Wow that was too easy, thanked!!
 
Old 02-08-2010, 12:46 PM   #10
gqchynaboy
LQ Newbie
 
Registered: Jul 2003
Posts: 20

Original Poster
Rep: Reputation: 0
I actually just noticed that sometimes I need to upload the images to a FTP server and when this happens their are uppercase letters in the file path, so it's spitting everything out. =[

Code:
grep -Eo 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"' *html

outputs:

img src="http://someFTPserver/Proj/Games/Creative/Mass_Effect_2/Code/R3/images/Spacer.gif"
I kept trying to play with grep so it only spits out 'Spacer.gif' or 'images/Spacer.gif' but not successful =.

Last edited by gqchynaboy; 02-08-2010 at 12:57 PM.
 
Old 02-08-2010, 04:57 PM   #11
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,301

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
Add the basename cmd http://linux.die.net/man/1/basename
 
Old 02-08-2010, 08:29 PM   #12
Tinkster
Moderator
 
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,988
Blog Entries: 11

Rep: Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880Reputation: 880
Quote:
Originally Posted by gqchynaboy View Post
I actually just noticed that sometimes I need to upload the images to a FTP server and when this happens their are uppercase letters in the file path, so it's spitting everything out. =[

Code:
grep -Eo 'img src=".*[A-Z].*\.[Gg][Ii][Ff]"' *html

outputs:

img src="http://someFTPserver/Proj/Games/Creative/Mass_Effect_2/Code/R3/images/Spacer.gif"
I kept trying to play with grep so it only spits out 'Spacer.gif' or 'images/Spacer.gif' but not successful =.
Marginally more involved ;}

Code:
egrep -o 'img src=".*/[^/.]*[A-Z][^/.]*\.[Gg][Ii][Ff]"'

And in action:
Code:
$ echo 'img src="http://someFTPserver/Proj/Games/Creative/Mass_Effect_2/Code/R3/images/spAacer.gif"' | egrep -o 'img src=".*/[^/.]*[A-Z][^/.]*\.[Gg][Ii][Ff]"'
img 
src="http://someFTPserver/Proj/Games/Creative/Mass_Effect_2/Code/R3/images/spAacer.gif"
$
$ echo 'img src="http://someFTPserver/Proj/Games/Creative/Mass_Effect_2/Code/R3/images/spacer.gif"' | egrep -o 'img src=".*/[^/.]*[A-Z][^/.]*\.[Gg][Ii][Ff]"'
$
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script for converting filenames to proper case? Yalla-One Programming 9 02-03-2010 02:37 AM
how do i restore lower case filenames in a source code package? unclejed613 Linux - Software 6 01-02-2010 09:33 AM
same filenames in a directory with different case venkat_eg Linux - General 2 08-15-2009 04:16 AM
script to list the filenames which are in lower case naveensankineni Programming 2 03-12-2008 07:09 AM
convert filenames case griv Linux - General 6 01-17-2002 11:10 PM


All times are GMT -5. The time now is 06:45 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration