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

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

ubuntu - Bash Script to Check That Files Are Being Created -