What do you mean by "Not working!"? Is it printing a diagnostic message? (If so, what is the message?)
What system are you using? On some systems, /usr/bin/sh may be a Bourne shell that doesn't recognize the $(...) form of command substitution. If that is the case, you could try:
Are you just saying that VALUE=$(func "Hi") didn't produce any output. If so, know that it shouldn't produce any output. If you wanted to see that the variable assignment worked as expected, you could use:
after the assignment to see what has been stored in the shell variable VALUE.
Not Working means function statements are not executed(no diagnostic msg either) so prompt is returned without any output.
i tried :
VALUE=`func "Hi'` did not work(above statement holds good here also)...
So, wat is it that i am missing here?
echo $VALUE yes i will add this line, but a question here can i get a string in VALUE from function? or can i return a string from function?
Both of the statements that you say are not working seem to be working just fine. Neither of them should produce any output. Both:
and
assign the text produced by func to the variable named VALUE (after stripping off the trailing newline). That assignment does not produce any output unless the shell detects an error while performing the assignment.
Note however, that the command:
is very different from the command:
because the opening quote and closing quote around Hi have to match.
yes, the execution is fine with no errors but at the same time no output(which is not wat is expected).
i am expecting the
echo "PRAMATER RECEIVED IS $1"
to get executed and is seen on STDOUT.
in any of the cases
VALUE=`func "hi"`
or
VALUE=$(func "hi")
Your expectation is wrong. That is not the way the shell works when you use command substitution in an assignment. The echo is executed, but it will not be seen on STDOUT because you are capturing the output and assigning it to a variable instead of writing it to STDOUT.
This User Gave Thanks to Don Cragun For This Post:
Hello.
System : opensuse leap 42.3
I have a bash script that build a text file.
I would like the last command doing :
print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt
where :
print_cmd ::= some printing... (1 Reply)
How to use "mailx" command to do e-mail reading the input file containing email address, where column 1 has name and column 2 containing “To” e-mail address
and column 3 contains “cc” e-mail address to include with same email.
Sample input file, email.txt
Below is an sample code where... (2 Replies)
Hi,
I have line in input file as below:
3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL
My expected output for line in the file must be :
"1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL"
Can someone... (7 Replies)
hi there, could use some basic PATH advice, i think, or something
find sometimes work, but which hasn't ever seemed to. for years!
what am i doing wrong that the commands which and find rarely work?
they used to work on the workstations i used ages ago...
running 10.5.8 because i... (4 Replies)
Hi Friends,
Can any of you explain me about the below line of code?
mn_code=`env|grep "..mn"|awk -F"=" '{print $2}'`
Im not able to understand, what exactly it is doing :confused:
Any help would be useful for me.
Lokesha (4 Replies)