- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- Troubles with cshell
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 09:09 AM
тАО06-08-2006 09:09 AM
Re: Troubles with cshell
LC_COLLATE is not even set. The system is pure english.
set field_1 = "2F2"
if ("$field_1" =~ ^[a-z]) then
echo "$field_1 IS OK"
endif
Output:
2F2 IS OK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 09:11 AM
тАО06-08-2006 09:11 AM
Re: Troubles with cshell
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 09:25 AM
тАО06-08-2006 09:25 AM
Re: Troubles with cshell
This line works fine:
if (`echo "$field_1" | grep '^[A-Za-z]' | wc -l`)
but with "=~" it doesn't ... I think I miss something in if.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 09:29 AM
тАО06-08-2006 09:29 AM
Re: Troubles with cshell
# cat tc1.sh
#!/usr/bin/csh
setenv field_1 $1
echo "1 = $1, field_1 = $field_1"
if ("$field_1" =~ [a-z]* ) then
echo "$field_1 IS OK"
else
echo "$field_1 NOT OK"
endif
exit
# ./tc1.sh 2F2
1 = 2F2, field_1 = 2F2
2F2 NOT OK
# ./tc1.sh hello
1 = hello, field_1 = hello
hello IS OK
# ./tc1.sh Hello
1 = Hello, field_1 = Hello
Hello NOT OK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 09:58 AM
тАО06-08-2006 09:58 AM
Re: Troubles with cshell
#!/usr/bin/csh
setenv field_1 $1
echo "1 = $1, field_1 = $field_1"
if ("$field_1" =~ [a-z]* ) then
echo "$field_1 IS OK"
else
echo "$field_1 NOT OK"
endif
exit
This script tests out okay on Linux c-shell.
I think the suggestion from the previous post will also work on sun.
SEP
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 10:06 AM
тАО06-08-2006 10:06 AM
Re: Troubles with cshell
The final regex, should match words that star with a-z or A-Z and after that contains only numbers and letters.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 10:16 AM
тАО06-08-2006 10:16 AM
Re: Troubles with cshell
echo "!!!"
being affect by history substitution and the leading "^" not matching front of string like bash, csh has a problem with locale. If you use a locale like LANG=en_US.iso88591 then the [a-z] range will include aBbCcDd...Zz because the collation order doesn't group the lowercase characters together. I don't know of any locale that would make [a-z] match 2.
The csh manual suggests using [[:lower:]] for a locale independent way to match lower case in file name patterns. That does work for file names. It doesn't work for =~.
- Tags:
- locale
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 10:20 AM
тАО06-08-2006 10:20 AM
Re: Troubles with cshell
And now I just need something after [A-Za-z] at the begining of the word, that will match any letter or number, like:
Alex342
aL3Lssd342
But not:
aL34_234
a324 234
etc.
I just can't make some stuff I found working in cshell ..
Thanx in advance.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 10:25 AM
тАО06-08-2006 10:25 AM
Re: Troubles with cshell
if ( "$field_1" =~ [a-z]* ) than
echo "$field_1 IS OK"
endif
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО06-08-2006 08:55 PM
тАО06-08-2006 08:55 PM
Re: Troubles with cshell
perhaps it is better to use a switch/case construct, which uses filename matching patterns:
switch ($field_1)
case [a-z]*:
echo starting lower case
breaksw
case [A-Z]*:
echo starting upper case
breaksw
default:
echo starting not with a letter
endsw
mfG Peter
- Tags:
- switch