LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (http://www.linuxquestions.org/questions/linux-general-1/)
-   -   lvm snapshot using script (http://www.linuxquestions.org/questions/linux-general-1/lvm-snapshot-using-script-769239/)

Ammad 11-15-2009 01:28 AM

lvm snapshot using script
 
Hi,

I am writing a script to create backup of data on LVM. when i try to put variable in place of size number it stops, and put error on console.

Code:


[root@swd data]# lvcreate --size $sumM --snapshot -n backup /dev/vg_swd/LogVol02
  Invalid argument --snapshot
  Error during parsing of command line.

Code:


whereas same command works without any error.
[root@swd data]# lvcreate --size 510M --snapshot -n backup /dev/vg_swd/LogVol02


catkin 11-15-2009 07:24 AM

The variable is $sum but the variable name given on the command is $sumM. Any of these will work
Code:

${sum}M
"${sum}M"
"$sum"M
$sum'M'
"$sum"'M'

The forms in which $sum (or $sum}) are in double quotes are more a little more robust in case $sum does not contain the expected integer but a value including whitespace such as space.

Ammad 11-15-2009 08:35 AM

thanks, catkin. i will check this.


All times are GMT -5. The time now is 08:18 AM.