All Questions

Tagged with
Filter by
Sorted by
Tagged with
3
votes
1answer
79 views

$-expansions not performed as expected when following a redirection

It seems that bash and zsh will perform the variable and arithmetic expansions in a child process when a) they're following a redirection operator like <, >, >> or <<<. b) the ...
0
votes
2answers
57 views

Bash String Manipulation and Assignment

How can I manipulate a string and then assign it to a variable? This string manipulation works as I want: echo ${dir:2:5} | sed 's/[.]$//'; but: var x = ${dir:2:5} | sed 's/[.]$//'; and x = ${...
4
votes
4answers
1k views

Why is foo=bar different from foo= bar? [duplicate]

What is the interpretation of the whitespace in this command foo= bar ? Why are foo=bar and foo= bar interpreted differently Example (Ubuntu bash) developer@1604:~$ foo=bar developer@1604:~$ foo= ...
10
votes
2answers
505 views

Assignments are like commands with an exit status except when there's command substitution?

See the following examples and their outputs in POSIX shells: false;echo $? or false || echo 1: 1 false;foo="bar";echo $? or foo="bar" && echo 0: 0 foo=$(false);echo $? or foo=$(false) || ...
-3
votes
1answer
148 views

Lexical analysis for assignment in a POSIX shell

For the lexical analysis in a POSIX shell, from http://pubs.opengroup.org/onlinepubs/007904875/utilities/xcu_chap02.html 7. [Assignment preceding command name] a. [When the first word] ...
1
vote
2answers
2k views

One line env variable set behavior [duplicate]

If I do this: SUMAN_DEBUG=foo echo $SUMAN_DEBUG I get no output but if I do: SUMAN_DEBUG=foo && echo $SUMAN_DEBUG then I get "foo" why is that?
1
vote
1answer
170 views

Different command outputs

I entered same command with a variable host. During 2nd time I entered blank space between host,= and $. Why it was trying to connect to a server ? Also, when I write like $(host name), I am getting ...
13
votes
3answers
5k views

Spaces in variable assignments in shell scripts

What is the difference between below variables assignments? var=23 var =23 var= 23 var = 23 Is there any difference in space around the assignment operator?
1
vote
0answers
80 views

How can I run speech to text and save the result in a variable?

I would like to speak into my computer's microphone, have what I say converted to text and then have that available as a shell variable. Is this possible? I thought I might do it using Google's ...
5
votes
1answer
2k views

Any problem assigning one variable to another in shell without using quotes? [duplicate]

This question is about assigning the entire contents of one variable to another variable. Variable is not being used (sent to echo, etc.) No parameter expansion is being done during the assignment. ...
8
votes
2answers
3k views

Variable assignment outside of case statement

In many languages it is possible to assign the result of a case/switch statement to a variable, rather than repeating the variable assignment many times within the case statement. Is it possible to ...