Use return value of a shell command as a value in shell script?
linux, shell
Solution
#!/bin/bash
variableA=$(ls)
echo $variableA
That should be your shell script assuming that you have `bash`
Then all you'd need to do is `chmod +x shell_script` to make it executable.
If you use `ls > contents.file` the result of `ls` is saved to a file called `contents.file`. Remember, `>` rewrites the entire file while `>>` appends to the last line.
Problem
Possible Duplicate: Capturing multiple line output to a bash variable For example I want to run ls command and take the return list as a value kept in a array in shell script. Something like run ``` #ls fileA fileB fileC ``` kept this return list in a variable that keeps a array ``` variable A = ["fileA","fileB","fileC"]; ``` I cannot give the exact notation for code since I do not know how to write shell script. After I learn this, I 'll.