Copy a variable in shell script (Linux)

linux, shell, terminal, unix

Solution

Note that `cp` is used to `copy files and directories`. To define variables, you just have to use the following syntax:

v=$1

Example

$ cat a
echo "var v=$v"
v=$1
echo "var v=$v"
$ ./a 23         <---- we execute the script
var v=           <---- the value is not set
var v=23         <---- the value is already set

Problem

How can I copy a variable to another variable in a shell script? Assuming the user has passed in `$1`, how can its value be copied to another variable? I assume it would look something like this... ``` cp $1 $2 echo "Copied value: $2" ```

Original source