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):
When I echo out the uncut lines (as is) compared to the cut lines, they match up to the point where I did the cut:
'*** 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??
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
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...
guys , i am using inotify for monitoring one directory to check core file generation , my snippet of code is follows
#!/bin/bash
DIR=$1
inotifywait -q -e create -m $DIR | while read path events name;
do
if ]; then
echo "Now I am going to do something with $name in directory $path."... (5 Replies)
Hi,
I've tried searching through the forum but I've drawn a blank so i'm going to post here. I'm developing a number of checks on a CSV file, trying to find if any are greater than a max limit. I'm testing it by running it from a command line.
The file I'm testing has 8 records. When I... (3 Replies)
Hi friend,
i have the following problem:
when i am writting the below command on the command prompt , its working.
while read -n 1 ch; do echo "$ch" ; echo "$ch" ; done<file_name.out.
but when i am executing it after saving it in a ksh file, its not working.
Please helppppppppp .. thankss... (18 Replies)
Hi,
can someone please help me!!! urgent!
I have a strange issue here. I grep for 2 strings from a txt files and compare the string value. Though the string values are the same, they are compared as different values. Please help
Case-1
--------
Here I grep for 2 different field values... (3 Replies)
This might be a dummy question, but is there a command in UNIX that compare two strings character-by-character and display the difference?
---------- Post updated at 11:25 AM ---------- Previous update was at 10:32 AM ----------
Or probably what I'm looking is how to break a string into... (3 Replies)
Another frustrating scripting problem from a biologist trying to manipulate a file with several millions line. For each of the line I need to compare the uppercase A or C or G or T with the lowercase a or c or g or t. If there are more uppercases, a + should be added to a new column, otherwise a -... (10 Replies)
Hello,
was just wondering how to compare strings in unix? I mean as in C there is a function strcmp() in string.h, is there any function in unix for that? I tried using
if
and all such variations but didn't succeed. Any help would be appreciated. Thanks in advance :) (9 Replies)
hi ,
i am trying to compre two strings
if ] or if ]
when the length of var1 is small (around 300-400 char ) it works fine
but when it is large (around 900-1000 chars) it fails
is there any limitations for this type of comparison ??? (1 Reply)
hi ,
i am trying to compre two strings
if ] or if ]
when the length of var1 is small (around 300-400 char ) it works fine
but when it is large (around 900-1000 chars) it fails
is there any limitations for this type of comparison ??? (3 Replies)
Hi,
Is there any limitation on the no of characters to be compared using the if statement in Unix. We had an issue while comparing the following two nos.
var1=20051031222900 & var2=20051101003545. The last six dgits are the time stamp for a day.
The if statement is like this:
if
then
move... (8 Replies)