05-31-2006
Quote:
Originally Posted by fgilain
Hi all,
I have a script where i need to check the format of a string.
finally, i'm waiting a "process name" and 2 numbers separated by a ","
string like : "this_is_a_string.txt,1,10 should be ok"
string ok : "apache.exe,1,10"
string ok : "mysqld,50,0"
string not ok : "ap ache,1,10"
string not ok : "ap,ache,1,10"
string not ok : " apache,1,10"
PS : "" characters are only here to be able to show a string beginning with a space...
Here is what i tryed :
if [[ $(expr "$PROCESS_STRING" : '^[a-z0-9\-\.\_]*,[0-9]*,[0-9]*$') -ne 0 ]];
then
echo " : String OK"
else
echo " : String KO"
fi
But i always get an error :
expr: WARNING: BRE not portable: « ^[a-z0-9\-\.\_]*,[0-9]*,[0-9]*$ »: use of « ^ » character as first character of a base regular expression isn't portable; canceled.
: Format OK
The problem seems to be the "^" character at the beginning of my regex, but if i remove it, a string like " apache,1,10" would be ok but it shouldn't in my case...
thanks for your help
Florent
What OS are you on?
It works fine with Solaris'
/usr/bin/expr and
/usr/xpg4/bin/expr
8 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
When I start ed as regular user, following message is displayed:
$ed
ERROR: tempnam failed: Permission denied
$
I think, following error produced in vi when search results from previous error:
No previous regular expression
Setting TMPDIR variable cause no effect.
As root all works... (6 Replies)
Discussion started by: frenki
6 Replies
2. UNIX for Dummies Questions & Answers
Dear all,
when I issue the command:
gunzip -c file.gz |sort
the command is executed normally and correctly but a message keeps appearing everytime I run the command:
the message:
sort: missing NEWLINE added at end of input file STDIN
Does anyone know what is the meaning of this message?... (3 Replies)
Discussion started by: marwan
3 Replies
3. Shell Programming and Scripting
Hi
I am getting few messages when trying to run my script from the following lines in the script
if test
then
// SomeCode
fi
The messages are as follows:
testing.sh: OBLIGOR_GROUP_ID: 0403-012 A test command parameter is not valid.
testing.sh:... (5 Replies)
Discussion started by: skyineyes
5 Replies
4. Shell Programming and Scripting
I just ran into this today, and don't know what to make of it...
if test x$SERVER = x
then
echo $USAGE
exit 1
fi
I know what everything in there does, except for the 'x' jazz... (2 Replies)
Discussion started by: jjinno
2 Replies
5. Shell Programming and Scripting
Hi
I want to do a regex test and branch based on the test result, but this doesn't seems to work :confused:
if \) ]]
then
echo success
else
echo failed
fi (1 Reply)
Discussion started by: subin_bala
1 Replies
6. Programming
Hi all
In the ltp-posix test,there is a case in open_posix_testsuite\conformance\interfaces\timer_gettime\speculative/6-1.c
I run the above code,it will has a segment fault, if I modify it to below,it works well
Anybody can tell me why? (1 Reply)
Discussion started by: yanglei_fage
1 Replies
7. AIX
We are getting this message on our AIX box. No one knows where its coming from. Where can I find any information on it?
Warning: file system free space is less than 10
file system total size = -2621440
file system available space = 2485160
file system used space = -5106592
file system... (3 Replies)
Discussion started by: t01scra
3 Replies
8. Shell Programming and Scripting
I have a code:
if
then#{ process daily files
for file in *_${Today}*.csv *_${Today}*.txt
do
if ||
then
echo "This file will be processed in separate script"
continue
fi
if ;then
... (2 Replies)
Discussion started by: digioleg54
2 Replies