0

What I'm trying to do: Completely replace a line that contains a certain string with another line (important: the line contains special characters like ./:).

What I've got so far:

sed -r -i 's#^.*blubb.*$#blubb./123::adsf#' test

This command works and replaces the line in the file "test" that contains "blubb" with "blubb./123::adsf".

I then wanted to issue the command on multiple machines with the help of pdsh, however this attempt resulted in "unterminated `s' command":

pdsh -g serverlist 'sed -r -i 's#^.*blubb.*$#blubb./123::adsf#' test'

How can I get rid of this problem? Any help would be appreciated!

Charlie28000
  • 67
  • 1
  • 5
  • 1
    Use double-quotes `pdsh ... "sed -r -i 's.....' test"` ? – iamauser Feb 21 '18 at 18:02
  • Unfortunately this results in the same error. `pdsh -g /path/to/serverlist "sed -r -i 's#^.*blubb.*$#blubb./123::adsf#' /path/to/test"` – Charlie28000 Feb 21 '18 at 18:15
  • Maybe helpful: https://stackoverflow.com/questions/30234546/running-shell-command-that-has-nested-quotes-via-ssh but I'm not sure if it's good enough to close as a suplicate – Barmar Feb 21 '18 at 18:21
  • Stack Overflow is a site for programming and development questions. This question appears to be off-topic because it is not about programming or development. See [What topics can I ask about here](http://stackoverflow.com/help/on-topic) in the Help Center. Perhaps [Super User](http://superuser.com/) or [Unix & Linux Stack Exchange](http://unix.stackexchange.com/) would be a better place to ask. – jww Feb 21 '18 at 23:20
  • What happens when you try a simpler sed 's' command (without `-i` or special characters) over pdsh? – Beta Feb 22 '18 at 00:35

0 Answers0