Testing for a simple script but I can't get this variable to cooperate with me. I've tried so many things, single quotes and doubles.
New=$(df -h)
sed -ie "200s|^.*$|"${NEW}"|g" "file.txt"
I'm trying to replace whatever is on line 200 of file.txt with the output of df -h pretty much.
Need help, if this has been asked before, sorry my brain is toasted and I'm not smart enough to comprehend.
most of the time i get an "unterminated `s'" error when I run the script. I'm thinking it's got something to do with the "{}" brackets around the variable and it being misread as something else in regex.
The output of
df -hhas whitespace so you need to keep it quoted to prevent word splitting. Compare:awkcould be more readable/maintainable here as you don't have to interpolate the data into the command string: