Well... there are some issues in your script. Let's see...
Code:
#!/bin/sh
v1= date |cut -d " " --fields=2,3,4
echo $v1
1. when assigning variables you should not put any blank space around the sign =.
2. to assign the output of a command to a variable (command substitution) you have to use the proper syntax. In the Bourne shell /bin/sh, this is done by sourronding the command with back ticks, as in
`command
`. In the Bourne Again shell /bin/bash, you can use also the syntax
$(command
). So these first lines will be:
Code:
#!/bin/sh
v1=`date | cut -d " " --fields=2,3,4`
echo $v1
The same apply to the second part
Code:
v2=`date | cut -d " " --fields=5 | cut -d: -f1`
echo $v2
3. to do string concatenation you have to put together the originating strings (as you already tried to do), but again don't leave any space around the sign =. Furthermore, if you want a blank space between the two strings you should use double quotes:
Code:
v3="$v1 $v2"
echo $v3
Just a note: to debug scripts you can run using
or bash -x if using the Bourne Again shell. This will give you a trace of all the commands executed by the shell, together with the variable or command substitutions.