Using Sed to Append Lines to File During Vagrant Provisioning

后端 未结 1 512
醉话见心
醉话见心 2021-01-25 02:21

I\'m currently using Vagrant to set up a development machine running Ubuntu. I want to add a few lines to my .profile that add directories to my $PATH

相关标签:
1条回答
  • 2021-01-25 03:03

    To fix "sed: -e expression #1, char 44: extra characters after command", escape \n, that is add another backslash to all \n:

    config.vm.provision "shell", inline:
    "sudo sed -i \'$ a if [ -d \\\"/usr/local/lib\\\" ] then\\n    PATH=\\\"/usr/local/lib:$PATH\\\"\\nfi\' /home/vagrant/.profile"
    
    0 讨论(0)
提交回复
热议问题