Seperating variable from immediately following letter
I have a variable $line which i determine earlier in my script.
Now im trying to use sed to insert some text at that specific line number. This works Code:
sed '7i\ Code:
sed "$linei\ Thanks |
Code:
${line}i |
sed "$line"i
|
Unspawn's answer is the best for general use, and schneidz's post leads to a good point; that you can concatenate multiple quoting patterns together:
Code:
sed "$line"'i\ But there's also simply this: Code:
sed "$line i\ |
Ended up using the multiquote method.
Thanks |
Good. I would've gone with either of the other options myself, as they tend to be easier to read, but it's your choice. If you're satisfied, please mark the thread as solved.
Check out these three links for more on how the shell parses arguments and whitespace. It's a vitally important concept when it comes to scripting. http://mywiki.wooledge.org/Arguments http://mywiki.wooledge.org/WordSplitting http://mywiki.wooledge.org/Quotes |
All times are GMT -5. The time now is 08:53 PM. |