I want to add a string with spaces at the end of each line of the output of
#!/bin/sh STRING_WITH_SPACES="this should be at the end of output" ls -lh | sed 's|$| '$STRING_WITH_SPACES'|'
The script above works fine when
$STRING_WITH_SPACES has no spaces:
-rw-r--r-- 1 me users 0 May 4 14:55 testfile thisshouldbeattheend
However when there are spaces in
$STRING_WITH_SPACES sed complains:
sed: -e expression #1, char 9: unterminated `s' command
How do I solve this?