How do I assign the output of a shell command to a shell variable under Unix like operating system? For example, I want to store the date command output to a variable called $now.
How do you do that?
var=$(/path/to/command arg1 arg2)
The content of test.sh
#!/bin/bash
PROD=$(ls -al)
echo "${PROD}"
the output
~$ bash test.sh |grep xen
drwxrwxr-x 3 user group 4096 Mar 7 2017 test_xen
drwxrwxr-x 3 user group 4096 Mar 7 2017 test_xen_4.7
No comments:
Post a Comment