### String condition test if [ -z "$ans" ]; then echo"you input nothing!" exit 1 fi
if [ "$ans" = "yes" ]; then echo"Yeah!!!!!!!!" elif [ "$ans" = "no" ]; then echo"Sorry to hear that!!!!!!!" elif [ "$ans" = "maybe" ]; then echo"You have make up your mind .-." else echo"unknow answer" fi
echo -n "plz input a num:" read INT
### [[ ]] supports regex if [[ "$INT" =~ ^-?[0-9]+$ ]]; then echo"yeah, you input a number, good boy!" else echo"your input is not a number!" exit 1 fi
### integer condition if [ $INT -eq 0 ]; then echo"zero" elif [ $INT -gt 0 ]; then echo"great than zero" else echo"less than zero" fi
echo -n 'if ((3%2)) result=' if ((3%2)); thenecho"true"; elseecho"false"; fi
echo -n 'if ((3%3)) result=' if ((3%3)); thenecho"true"; elseecho"false"; fi
echo -n 'if ((3 > 2)) result=' if ((3 > 2)); thenecho"true"; elseecho"false"; fi
echo -n 'if ((3 < 2)) result=' if ((3 < 2)); thenecho"true"; elseecho"false"; fi
echo -n 'if ((3 == 3)) result=' if ((3 == 3)); thenecho"true"; elseecho"false"; fi
## command1 || command2; if command1 is false, then run command2 [ -d dir ] || mkdir dir
$ sudo vgdisplay -v vg2 Password: Using volume group(s) on command line. --- Volume group --- VG Name vg2 System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size 3.63 TiB PE Size 4.00 MiB Total PE 951243 Alloc PE / Size 951043 / 3.63 TiB Free PE / Size 200 / 800.00 MiB VG UUID
--- Logical volume --- LV Path /dev/vg2/volume_2 LV Name volume_2 VG Name vg2 LV UUID LV Write Access read/write LV Creation host, time , LV Status available # open 1 LV Size 3.63 TiB Current LE 951040 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 4096 Block device 249:1
--- Physical volumes --- PV Name /dev/md3 PV UUID PV Status allocatable Total PE / Free PE 951243 / 200
逻辑卷挂载信息:
1 2
$ mount | grep vg2 /dev/mapper/vg2-volume_2 on /volume2 type btrfs (...)