I want to change the default value on all machines to default=0

default value could be any integer number

how to set in the sed syntax that default could be any number

my example ( not working )

for server_ip in $all_servers
   ssh $server_ip  "sed -i s'/default=[0-9]/default=0/g' /etc/grub.conf"

example of grub.conf

  more /etc/grub.conf
  # grub.conf generated by anaconda
  # Note that you do not have to rerun grub after making changes to this     file
  # NOTICE:  You have a /boot partition.  This means that
  #          all kernel and initrd paths are relative to /boot/, eg.
  #          root (hd0,0)
  #          kernel /vmlinuz-version ro root=/dev/rootvg/slash
  #          initrd /initrd-version.img
  • 1
    How does this not work ? What error messages do you see ?
    – user9517
    Sep 5, 2016 at 10:16
  • hi lain , this is my mistake , I not tested because I was thinking that my syntax is wrong , I test the script and script is working fine , do you have the ability to delete the question , because I dont have
    – dandan
    Sep 5, 2016 at 10:26
  • Your script doesn't work as written because for example all-servers is an illegal variable name.
    – user9517
    Sep 5, 2016 at 10:29
  • 2
    If you have so many serers that you need to run scripts on many of them in this manner, you shouldn't be running scripts in this manner. There are a number of config management systems such as puppet or ansible; now would be a very good time to look at them.
    – Jenny D
    Sep 5, 2016 at 10:39

1 Answer 1


The script in the original version of your question contained an error in that the variable name all-servers is illegal. The - character is not allowed in a shell variable name.

Valid characters are [A-Za-z0-9_].

Not the answer you're looking for? Browse other questions tagged or ask your own question.