hi
I have template file my.tpl:
bla-bla-bla
<link href="style.css" type="text/css">
bla-bla-bla
and style.css :
body{margin: 0px;}
I want to get in result one file:
bla-bla-bla
<script>body{margin: 0px;}</script>
bla-bla-bla
I tryed to used SED:
sed '/<link .*href=\"([^\"]*)*\" .*>/{
r \1
d
}
' my.tpl > result.tpl
but it was not working.
Help me please. How can I resolve my task with SED or AWK? Thanx.
egrep -o "<link[^>]+>" < infile > outfile
It's find only matched pattern. How can I use it to replace by filename pattern?
Oh, I see... I thought you meant the name of the file for some reason, not a file link.
$ echo '<link href="style.css" type="text/css">' | sed 's#<link [^>]*type="text/css">#<script>body{margin: 0px;}</script>#g'
<script>body{margin: 0px;}</script>
$
corona688:
Oh, I see... I thought you meant the name of the file for some reason, not a file link.
$ echo '<link href="style.css" type="text/css">' | sed 's#<link [^>]*type="text/css">#<script>body{margin: 0px;}</script>#g'
<script>body{margin: 0px;}</script>
$
good, thanx. it's work with static content when I know filename.
But script should be work for dynamic files when he don't know css-file name. He should determine css file name and insert css-content directly to tpl-file.
ookay...
What's your system? do you have GNU awk?
dim_nsk
October 14, 2011, 11:26pm
7
My system is Cygwin.
I have AWK on it.