Issues with expr command on Solaris Box


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Issues with expr command on Solaris Box
# 8  
Old 06-09-2010
Quote:
Originally Posted by ripat
This pattern /^\S+\@test.com$/i will match anybody@testscom. Shouldn't the dot be escaped?
Hello ripat,

Indeed it should be escaped.
but that kind of input is unlikely of course.

Regards,
Gaurav.
# 9  
Old 06-10-2010
MySQL

Quote:
Originally Posted by suffisandy
Hello Friends,

I have written a code on a Linux box, however, am getting issues while running it on a Solaris server. The issue with Sed command is sortd out, however, am still lokking for solutions with expr command. Here is the issue,

Linux :

Code:
 bash-2.03$ expr match singh@test.com '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'
singh@test.com
bash-2.03$

Solaris :

Code:
bash-2.03$ expr match singh@test.com '\(^[a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]$\)'
bash-2.03$

The output in solaris is blank. Could anyone please let me know what changes can I make in this command to make it work.

Any suggestions would be greatly appreciated !!!

Moderator's Comments:
Mod Comment Please use code tags, ty
Try this Smilie

Code:
bash-2.03$ expr match singh@test.com '\([a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]\)'
singh@test.com


Regards
░ ygemici
# 10  
Old 06-12-2010
@ ygemici ... thanks for the reply ... though this will not give an exact match, see the below one

bash-2.03$ expr match singh@test.comtest '\([a-zA-Z0-9\w\.\_\-]*@[Tt][Ee][Ss][Tt].[Cc][Oo][Mm]\)'
singh@test.com
bash-2.03$

---------- Post updated at 01:15 PM ---------- Previous update was at 01:13 PM ----------

Hey Gaurav,

I guess S+ would allow only alphabets to be matched ... I need a regex which would allow a combination "-, _, ., alphabets and numerals" as input for email address.

---------- Post updated at 01:20 PM ---------- Previous update was at 01:15 PM ----------

Quote:
Originally Posted by ripat
Why don't you try with grep:


Code:
~$ echo 'singh@test.com' | grep -qi '^[a-z0-9_-.]\+@test\.com$' && echo 'got a match' || echo 'failed'

> got a match



$ echo 'singh@test.coms' | grep -qi '^[a-z0-9_-.]\+@test\.com$' && echo 'got match' || echo 'failed'

> failed

Hey Ripat,

Am getting following error while using grep command,

Code:
bash-2.03$ echo 'singh@test.com' | grep -qi '^[a-z0-9_-.]\+@test\.com$' && echo 'got a match' || echo 'failed'
grep: illegal option -- q
Usage: grep -hblcnsviw pattern file . . .
failed
bash-2.03$


Last edited by Scott; 06-18-2010 at 03:51 PM.. Reason: Code tags, PLEASE!
# 11  
Old 06-12-2010
hello

Quote:
Hey Gaurav,

I guess S+ would allow only alphabets to be matched ... I need a regex which would allow a combination "-, _, ., alphabets and numerals" as input for email address.


Code:
gaurav@localhost:~$ echo singh_.@test.com | perl -wln -e 'print if /^\S+\@test.com/i'
singh_.@test.com
gaurav@localhost:~$ echo singh##___.@test.com | perl -wln -e 'print if /^\S+\@test.com/i'
singh##___.@test.com
gaurav@localhost:~$

\S matches any non-space characters which includes dot,@,# or any special characters.

Regards,
gaurav.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Issues with 'expr'

Hi, I have a text file where i define all the inputs to my shell script: IP=1.2.3.4 PC=1234 In the shell script, i am trying to read the input variables from the above mentioned text file: #!/bin/bash #usage IP=expr cat /tmp/input.txt | grep IP| cut -d "=" -f2 PC=expr cat... (4 Replies)
Discussion started by: akarnya
4 Replies

2. Shell Programming and Scripting

Issues for script that login to a unix box

Hi, I have a script that should login to a different box then the box that i am in and run the commands. I have the script sample below that logins to a unix box and get the files .Looks like ls-lrt command is not running or its wrongly used. #!/bin/bash # Ask the user for build month... (5 Replies)
Discussion started by: learninguser235
5 Replies

3. Solaris

Reboot solaris box(What are all the command outputs)

Hi What are all the command outputs we have to note and keep it for safe before rebooting or shutting down a solaris box (5 Replies)
Discussion started by: newtoaixos
5 Replies

4. UNIX for Dummies Questions & Answers

DNS on Unix box issues

Hi Guys, Just wanted to seek your assistance on an issue encountered with one of our client DNS server query. we have 2 sets of DNS servers.. internal and external. For Internal to reach the external DNS server (DMZ) it has to go through 2 FWs. Current settings: - FW rules for Internal... (3 Replies)
Discussion started by: Hotshot8259
3 Replies

5. UNIX for Dummies Questions & Answers

Transferring files Permission issues in remote box

Hi, I have a directory 'data' which is a symbolic link to /var/opt/store/rawdata/appname on a remote box. I am not able to SFTP some files from my local box to this dir. in the remote box. Also I am not able to copy or move the files in the robot id home dir. in remote box to this data dir... (2 Replies)
Discussion started by: vharsha
2 Replies

6. Shell Programming and Scripting

Expr issues

I have two variables that are set by a number i.e. recs_on_db=12 yesterdays_recs_on_db=10 i need to get the difference between the two and be able to set this in a variable I have tried expr but does not work: db_difference=`expr $recs_on_db - $yesterdays_recs_on_db` i get: expr:... (2 Replies)
Discussion started by: Pablo_beezo
2 Replies

7. Shell Programming and Scripting

expr inside a ksh script Solaris

Hi; If I do something like this. dftotalsize=0;export dftotalsize;df -k | grep \/db001 | awk '{print $4}' | while read theinput \ ; do export $theinput; dftotalsize=`expr $dftotalsize + $theinput`; export dftotalsize; echo $dftotalsize; done ; echo `expr $dftotalsize \/ 1024 \/ 1024 "GB" Is... (4 Replies)
Discussion started by: myjess
4 Replies

8. UNIX for Dummies Questions & Answers

I need an scp command from a unix box to a windows box.

scp file="myfile.txt" todir="user@somehost:(M:drive:/somepath/)"/ Not sure I need it to go to a specific drive on the windows box (1 Reply)
Discussion started by: xgringo
1 Replies

9. UNIX for Dummies Questions & Answers

difference between AIX box and Sun Solaris box

Hi, I need a clarification. Is there any difference between AIX box and Sun Solaris box? The bzip command with -c option works in AIX box and the same does not work in Sun Solaris box. Can anyone please explain if there is an implementation difference in both these boxes for the shell... (1 Reply)
Discussion started by: nisha4680
1 Replies

10. UNIX for Dummies Questions & Answers

how to mount a hotswap scsi drive on a solaris 2.6 netra box using the mount command?

Hi... question is this: How do I mount an LVD hotswap scsi drive in bay #2 on a netra using the mount command? volmgt doesn't seem to mount it and/or I don't know how to view the drives data if it's formatted which it may not be. This drive is not new out of the box so I'm not sure. ... (4 Replies)
Discussion started by: soulshaker
4 Replies
Login or Register to Ask a Question