![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| get rid of special characters | vakharia Mahesh | UNIX and Linux Applications | 4 | 07-29-2008 01:36 PM |
| Special Characters in directory name | tez | UNIX for Dummies Questions & Answers | 6 | 08-14-2006 07:06 PM |
| how to see special characters in a file using vi | jingi1234 | UNIX for Dummies Questions & Answers | 6 | 10-19-2005 11:57 AM |
| special characters | nawnaw | UNIX for Dummies Questions & Answers | 2 | 05-18-2004 03:17 PM |
| awk/sed with special characters | apalex | Shell Programming and Scripting | 5 | 05-06-2002 04:40 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Comparing Special characters (i.e. -,\,/) in an if statment
I need to validate the special characters of a date (the characters between the year and month & month and day). The data filed is being populated by users and read into the script vi an argument. I want to ensure that the date is a '-' (dash) and not a '/' or '\' (slash).
The every thing I have tried has failed and I have run out of ideas. I'm new to scripting and don't know where else to turn. Please help if you can. Thanks. # ! /bin/ksh set -x V_DATE='2008-08-30' echo $V_DATE V_DATE_DASH1=`echo $V_DATE | cut -c 5` echo 'INFO V_DATE_DASH1: ' $V_DATE_DASH1>>${LOGFILE} V_DASH='-' echo 'INFO V_DASH:'$V_DASH>>${LOGFILE} echo $V_DATE_DASH1 = $V_DASH if `${V_DATE_DASH1} = ${V_DASH}` then echo 'INFO V_DATE_DASH1 is OK'>>${LOGFILE} else echo 'ERROR V_DATE_DASH1 not a "-" '>>${LOGFILE} usage fi |