mercredi 4 mars 2015

How to grep over a variable


I have a scenario like



VAR = `Some command brings the file path name and assigns it to VAR`


For example VAR can have value like /root/user/samp.txt


I want to grep command like



grep HI $VAR


This doesnt works gives an error saying cannot open /root/user/samp.txt same error when tried cat $VAR.


How to handle this ?


I have given try



echo $VAR | grep HI
grep HI "$VAR"


Using korn shell



Aucun commentaire:

Enregistrer un commentaire