We help IT Professionals succeed at work.
Get Started

variable not being used correctly by grep in shell script

mickt
mickt asked
on
85 Views
Last Modified: 2015-06-23
I'm writing a script to resize vagrant boxes.  I'm struggling with a section, which is supposed to close media.  I provide the path to the vmdk file and the new size to the script.

An example path is /root/.vagrant.d/boxes/test-80/1.0.0/virtualbox/packer-centos-7.0-x86_64-disk1.vmdk

The section is as follows:

for disk in `$execsudo vboxmanage list hdds | grep -B4 $1 | grep - | grep UUID | awk \ '{print $2}'`
  do
      $execsudo vboxmanage closemedium disk $disk
  done

It is not correctly using $1.  I've tried various quoting etc.  I'd appreciate some assistance.
Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015
Commented:
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE