#! /bin/sh
abcd = "Hello world"
if [ `grep "$abcd" file1` -gt 0]
then
echo $abcd
fi
i got error message that
line3 : abcd: command not found
line5 : [0: command not found
line5 : [1: command not found
i have no idea why i got this message. Can some one help me ???
if [ `grep -c "$abcd" file1` -gt 0];
then
echo $abcd
fi
cheers,
Devaraj Takhellambam
watch out for spaces around [ and ]
if [ `grep "$abcd" file1` -gt 0 ]
And...remove the spaces around the equal sign:
abcd="Hello world"
Regards
abcd="hello world"
echo $abcd
thanks for your help!! but!!
I removed all the white spaces but i still got error message
for this command i got an error message
abcd: command not found.
Maybe your shell don't like the syntax, try this:
#!/bin/sh
abcd="Hello world"
grep "$abcd" file > /dev/null
if [ $? -eq 0 ]
then
echo "$abcd"
fi
thanks everyone !! all solved !!!