[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Re: [NOVICE] replace i asp / htm filer



Hejsa Danjel

Den 9. jul. 2012 08.37 skrev Danjel Jungersen <sslug@sslug>:

> Hejsa.
>
> Jeg har en ordeltlig røvfuld filer, hvor jeg skal have sat noget ind
> (en includefil med google analytics).
>
> Jeg havde regnet med at søge på
> "
> </head>
> "
>
> Og erstatte med
> "
>
> <!--#include file="include/header.inc" -->
>
> </head>
> "
>
> Jeg ved at det kan lykkes med linux, men kan ikke huske hvordan :-)
>

En mulighed er at benytte programmet sed (burde være med i din linux
installation).

Jeg har fundet denne side
http://stackoverflow.com/questions/1251999/sed-how-can-i-replace-a-newline-n

og lavet en sed kommando som burde gøre det du efterspørger:

sed  ':a;N;$!ba;s|\n</head>|\n<!--#include file="include/header.inc"
-->\n\n</head>|' test.html

sed er navnet på kommandoen
test.html er navnet på en fil jeg har lavet (inkluderet nederst)

Når det skal køres på mange filer (efter du har testet at det virker) så
kan du bruge "-i" muligheden til sed så vil den overskrive filen direkte
(default er at skrive til terminalen).

Jeg håber det kan bruges.
mvh
Folmer



-- indhold af test.html --
<head>
something here
next line empty

</head>

something else here
-- indhold af test.html --

-- output efter sed kommando --
<head>
something here
next line empty

<!--#include file="include/header.inc" -->

</head>

something else here
-- output efter sed kommando --







> Nogen der lige kan pege mig i den rigtige retning?
>
> De venligste hilsener
> Danjel
>
> sslug-novice: Listen for begynder-relaterede spørgsmål
>
>


-- 
Folmer Fredslund


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2012-08-01, 02:01 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *