How Do I Store a Grep Value in a Variable in Unix?
Contents How Do You Store Grep Value in a Variable? the Syntax Is: Var=`Command-Name` Var=”`Grep Word /Path/to/File`” ## or ## Var=$(Command-Name) Var=”$(Grep...
Contents
How do you store grep value in a variable?
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”
6 янв. 2017 г.
How do you store a value in a variable in UNIX?
To store the output of a command in a variable, you can use the shell command substitution feature in the forms below: variable_name=$(command) variable_name=$(command [option …] arg1 arg2 …) OR variable_name=’command’ variable_name=’command [option …]