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
How obtain a text selection in report like it is possible in Form
Multiple instances of RunDll32.exe on server
Bash sort / cut / uniq script to analyze domains
Unable to import text file into table in Microsoft Access 2003
Outlook can't connect to incoming mail server - but can ping it - what setting am I missing?
grep on multiple items
Update fields from data in the same table
Push image to multiple computers using a network switch
DS_E_Communications_Proble<wbr />m error message trying to run Exchange Admin from Win2k Professional
how to check that SNMP service is running and comunity permission