Quickly add multiple lines to a vmx file

On a customer site I had to add multiple lines (CPU mask)to more than 30 virtual machines configuration files (vmx).
Of course you can vi to every vmx file and add the lines, but this consumes a lot of time! So I search for a easier (less time consuming) option.
The method I found is maybe not the most complex or nice one, but it works.
I just use the echo command on the prompt. The syntac is:

echo -n ‘line1nline2nline3’ >> vm.vmx

I guess you all now what echo does:-) The -n option witch enables interpretation of backslash escapes(which is off by default). Replace line1, line2 and line3 with your own text line. The n option gives a new line. The >> vm.vmx option tells bash to add the lines produced by echo on the end of the vmx file.

So a command could be:

echo -e ‘cpuid.1.ecx = “——–0–00——————-“ncpuid.80000001.eax = “——————————–“ncpuid.80000001.eax.amd = “——————————–“ncpuid.80000001.ebx = “——————————–“ncpuid.80000001.ebx.amd = “——————————–“ncpuid.80000001.ecx = “——————————–“ncpuid.80000001.ecx.amd = “——————————–“ncpuid.80000001.edx = “—-0——H——————–“ncpuid.80000001.edx.amd = “———–H——————–“‘ >> vm.vmx

Maybe there is a nicer solution, if so let me known!

About Michael
Michael Wilmsen is a VMware training/consultant (no specific order) with more than 15 years in the IT industry. Main focus is VMware vSphere, Horizon View and Site Recovery Manager with a deepdive to performance. Michael is VCDX 210, VCAP 4/5 certified, has been rewarded with the vExpert title from 2011, is a PernixPro, Nutanix Tech Champion and a Nutanix Platform Professional.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

You must be logged in to post a comment.