How do I store a grep value in a variable in UNIX?
Answer
The syntax is:
Answer
The syntax is:
- VAR=`command-name` VAR=”`grep word /path/to/file`” ## or ## VAR=$(command-name) VAR=”$(grep word /path/to/file)” …
- echo “Today is $(date)” ## or ## echo “Today is `date`” …
- todays=$(date) …
- echo “$todays” …
- myuser=”$(grep ‘^vivek’ /etc/passwd)” echo “$myuser”