What is wrong with following bash script?
Two things:
- There can be no spaces between name of the variable, the
=
signal and the value of the variable -
If you want to put the results of a command or series of commands on a variable, you must enclose it on
$(command)
or old style backticks. Both lines below are correct and do the same thing:a=`commands` a=$(commands)
So your line must be
a=$(grep -n mark /etc/samba/smb.conf |cut -d: f1)
There are some differences on how to concatenate the use of backticks or new style $()
, check this question on SO to see a good response.
a=`grep -n mark /etc/samba/smb.conf |cut -d: -f1`
Try this instead
a=$(grep -n mark /etc/samba/smb.conf |cut -d: f1)
Or instead of the $() you could use backticks (which here turn on the nice code look)
Should be a=$( ... )
or
a=` … `
Maybe by trying to use cut like this:
a=`grep -n mark /etc/samba/smb.conf |cut -d: -f1`