I�m trying to modify someone perl script to fix a bug. The piece of code checks that the zone name you want to add is unique. However, when the code runs, it finds a partial match using grep, and decides it already exists, so the �create� command exits.
$cstatus = `${ZADM} list -vic | grep ${zoneName}`;
At the shell, it�s this: zoneadm list -vic | grep ${zoneName}
I have an old zone name called cscndmndc006-old. I wanted to create a new zone name called cscndmndc006.
I tried grep �w but that still got a partial match.
The -w option on grep isn't going to work as it appears that the zone name contains 'non-word' characters (a dash). Since this seems a pretty specific application in terms of your input (it seems that the data you are searching for is always in column 2), then something as simple as this might work for you:
grep " $zonename " filename
This will match the name you are checking with something in the file only if the string in the file has a leading and trailing space.
If the columns are separated by either a space or tab, then something like this would work (assuming egrep is available):
Thanks for the replies. ec01, I like your solution as I prefer not to have to save the result to a file. I tested it and it works as advertised. Thanks again.