Microsoft
Software
Hardware
Network
Question : How to do linux bash script using do and if statement ?
Hi,
I would like to display only the following output from the following command :
/usr/sbin/vzlist -ao veid
The original Output is :
CTID
1
107
111
112
116
117
121
126
127
128
I would like my bash script to OMMIT the CTID and only display the rest.
I have tried with the following script but it come out with error :
#!/bin/bash
for i in $(/usr/sbin/vzlist -ao veid|more +2)
do
if [$i -eq 'CTID'] ; then
echo ""
elif [$i != 'CTID'] ; then
echo $1
fi
done
The error are as follows :
[root@vps1 /]# ./backupve.sh
./backupve.sh: line 5: [CTID: command not found
./backupve.sh: line 7: [CTID: command not found
./backupve.sh: line 5: [1: command not found
./backupve.sh: line 7: [1: command not found
./backupve.sh: line 5: [107: command not found
./backupve.sh: line 7: [107: command not found
./backupve.sh: line 5: [111: command not found
./backupve.sh: line 7: [111: command not found
./backupve.sh: line 5: [112: command not found
./backupve.sh: line 7: [112: command not found
./backupve.sh: line 5: [116: command not found
./backupve.sh: line 7: [116: command not found
./backupve.sh: line 5: [117: command not found
./backupve.sh: line 7: [117: command not found
./backupve.sh: line 5: [121: command not found
./backupve.sh: line 7: [121: command not found
./backupve.sh: line 5: [126: command not found
./backupve.sh: line 7: [126: command not found
./backupve.sh: line 5: [127: command not found
./backupve.sh: line 7: [127: command not found
./backupve.sh: line 5: [128: command not found
./backupve.sh: line 7: [128: command not found
[root@vps1 /]#
Appreciates if anybody can help which line is wrong from my script and provide me with the correct script.
Thanks.
Answer : How to do linux bash script using do and if statement ?
if [ $i == 'CTID' ] ; then
echo ""
elif [ $i != 'CTID' ] ; then
echo $i
fi
Random Solutions
Group Policy Win 2003
Javascript visiblity
ajax Collapsible Panel Content NOT on page load.
Ghost 2003 won't work with SATA CDROM
Install win98 without scandisk
w32 self extractor
Oracle "timeout" problem
The Best Drawing Tools
Biz Hubs Campatility to Citrix Presentation Server 4.5
Running Norton Ghost 8 using a USB Hard Drive