LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Shell script question (https://www.linuxquestions.org/questions/linux-newbie-8/shell-script-question-323410/)

paraiso 05-14-2005 09:31 AM

Shell script question
 
I want to check if the name of a file($x) is inside the file($fileName)but it doesn't work. What could it be ?

Code:


read x
       
awk '{ print $2 }' $fileName | grep -i $x
       
       
if [ $? -gt 0 ]
then
       
 do that

else
       
 do this
       
fi


Cheers

paraiso 05-14-2005 10:37 AM

just found out that the solution to my problem was to check if the command exit statue was equal to 0.

if [ $? -eq 0 ]


Bye

mohit dhawan 05-15-2005 01:55 AM

nice to answer ur own posts :wink


All times are GMT -5. The time now is 07:19 PM.