sh - Executing a shell script from a file -



sh - Executing a shell script from a file -

my os platform : sunos machinehull01 5.10 generic_148888-05 sun4v sparc sunw,sun-fire-t200

i have written shell script run file

file name: test.sh

#!/bin/sh varname=$grep '-l' testword /home/hull/xml/text/*.txt echo "found $varname"

when run above command in console i'm getting right output without errors, when run sh test.sh or ./test.sh i'm getting below error

test.sh: -l: not found found

can please help me on this?

you searching called "command substitution" :

varname=$(grep -l testword /home/hull/xml/text/*.txt) echo "found $varname"

it execute command between $( , closing parenthesis ) in subshell , homecoming output of command varname.

shell sh sunos

Comments

Popular posts from this blog

c# - ASP.NET MVC Sequence contains no matching element -

java - Parsing XML, skip certain tags -

rest - How to invalidate user session on inactivity in a stateless server? -