You are not logged in.

#1 2011-01-29 17:46:29

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,672
Website

sed usage confusion [SOLVED]

I want to insert the contents of a file into another file via sed.  This works:

#!/bin/bash
cd /foo
tree -DC -T "Title" -H "http://url" --charset=utf8 -o /tmp/junk

cd /tmp
sed '/<h1>/ {
r /home/facade/addition
d
}' <pre >index.html

What I can't seem to do is substitute $HOME into that read statement to make it user independent.  Any sed gurus out there know how to pull it off?

Last edited by graysky (2011-01-29 17:54:09)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2011-01-29 17:48:38

falconindy
Developer
From: New York, USA
Registered: 2009-10-22
Posts: 4,111
Website

Re: sed usage confusion [SOLVED]

It's an issue of shell quoting, and not specific to sed:

#!/bin/bash
cd /foo
tree -DC -T "Title" -H "http://url" --charset=utf8 -o /tmp/junk

cd /tmp
sed '/<h1>/ {
r '"$HOME"'/addition
d
}' <pre >index.html

Offline

#3 2011-01-29 17:53:52

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,672
Website

Re: sed usage confusion [SOLVED]

@falconindy - Nice, thanks for that.  Works great.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB