![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | 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 !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Problem in ksh script ( String comparison ) | amarnath | AIX | 1 | 07-18-2006 03:40 AM |
| Problem in ksh script ( String comparison ) | amarnath | Shell Programming and Scripting | 3 | 07-13-2006 09:14 AM |
| Problem deleting file with special character | hart1165 | UNIX for Dummies Questions & Answers | 2 | 12-07-2005 07:29 AM |
| comparison problem | ranj@chn | Shell Programming and Scripting | 8 | 11-05-2005 03:03 AM |
| rsync problem - space character in filename | chief2 | UNIX for Dummies Questions & Answers | 3 | 09-24-2004 08:06 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
|||
|
character comparison problem
I have three lines in a log that I want to check to make sure that they say the following (mm/dd/yyyy and hh:mm:ss changes depending in when the log is generated):
'*** Testing file for mm/dd/yyyy' '*** End of procedure! Time was: hh:mm:ss' '*** End ***' I did some sed and cut and ended up with something like this (the constant portion): Code:
if [[ $first = '*** Testing file' ]] && [[ $second = '*** End of procedure Time was:!' ]] && [[ $third = '*** End ***' ]]; then do something else handle error fi '*** Testing file for mm/dd/yyyy' '*** Testing file for' '*** End of procedure! Time was: hh:mm:ss' '*** End of procedure! Time was' '*** End ***' '*** End ***' Technically, my if-then statement matches the cut lines but the else ALWAYS gets executed even though the test echo statements I did seemt to match exactly to the dot...what is going on?? I can't figure it out. I thought it was some blanks somewhere but that did not appear to be the case. Anyone?? Gianni added code tags for readability --oombera Last edited by oombera; 02-20-2004 at 06:42 AM. |
| Forum Sponsor | ||
|
|
|
|||
|
The '!' in the wrong position was a typo but that didn't do anything..I'm still getting the error like it is not matching.
Also, is that wrong to write an if-else-then like that or you're just making an observation. I have tons of codes with that type of if-else-then...hehe Thanks. |
|
|||
|
Would be even better if someone can help me figure out how to check for the entire line content, keeping in mind that the pattern would still be:
*** Testing file for mm/dd/yyyy' '*** End of procedure! Time was: hh:mm:ss' Would this make sense for pattern mm/dd/yyyy in the first line? [0-1][0-2]/[0-3][0-9]/200[3-9]? Thanks. |
|
|||
|
It didn't work when I made the change as you've suggestd. Still causing error handling to be performed. It is only a problem on those lines where I did the cut. If I compare the line as is (last line) then it always executes successfully. This is why I am not sure if it is something else. I am not sure why the trimmed lines would be a problem though because what I trimmed and what I compared the trimmed lines to are identical as far as I can tell...
|