jwall was correct when (s)he said that the command should be
grep "$time" rather than
grep $time.
The original command pipeline expects grep to search standard input for the string specified in the envvar
time, which it will do if it is given an unique argument. In the latter case, the shell expands
$time into
Abr 04 which grep interprets as two arguments separated by a space, and tries to find the string
Abr in the file
04. Hence the error. The other number in the error message is an error code from the command (smells like AIX from here ...).
Putting
grep '$time' into a script will not work. We want the shell to expand the envvar, wheras this will tell grep to find the literal string
$time in stdin.
Alex
Quote:
Originally posted by mshankars
hello pooja,
We can use both the commands date +%d and date +%h to get the month . The problem lies at the &time instead of '&time' .He said he can get it correctly when he wexecutes manually. But if he runs as a script he needs to give '&time' .Am I right?
|