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
Content editor webpart displaying incorrectly
Cannot launch web links from outlook 2003 email
MS Access 2007 - Does this product take advantage of multiple processors?
catch md5sum output
Remote Desktop Clients Cannot Access Their Local Printers unless they are in Domain\Admin Group
Access Bar Chart Colors...
employee getting married
Password Complexity Policy - SQL Server 2005
Passing Variables in URL String
How to use Decimal Data Type in VBA code