Home > OS >  Refer to question the Linux command execution
Refer to question the Linux command execution

Time:11-09

Learning encountered such a situation the sum again today. TXT file contains 1-5 number in the command line:

The cat sum. TXT | echo $[$(tr '\ n' '+') 0] will prompt illegal variable name! I write this. Execution is no problem in sh
For this is why

CodePudding user response:

This is not simple, I don't know

You are can use the bash, even under the command line can output 15,
But you can't use the ZSH, but my mistake is the input/output error,

In sh, you if statement #!/bin/ZSH, there will be two cases
1.
./file. Sh 
after the operation, the command line waiting for input
2.
../file sh 
after the operation, at the same wrong

If you use ZSH and at the command line to run successful, use {}
 cat sum. TXT | {echo $[$(tr '\ n' '+') 0]; } 

CodePudding user response:

Direct copy, no error

CodePudding user response:

refer to the second floor emperor royal thunder response:
copy directly, no error

Emmm, brother your $/bin/bash SHELL?

CodePudding user response:

reference zZMZ_ reply: 3/f
Quote: refer to the second floor emperor royal thunder response:
copy directly, no error

Emmm, brother your $/bin/bash SHELL?


yes
  • Related