[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: [PROGRAMMERING] subst med xargs sed



Mogens Valentin <sslug@sslug> writes:

> Jeg kan ikke få substituering i mange filer til at virke, à la:
>
> grep -rl oldname /etellerandetdir/* |xargs sed s/oldname/newname/g
>
> Jeg har den fikse ide at det skal være en  xargs sed  konstellation,
> fordi jeg aldrig har fået taget mig sammen til at bruge det før ;)

Jeg plejer at overse sed og bruge perl:

grep -rl oldname /etellerandetdir/* |xargs perl -i -pe s/oldname/newname/g

Den vigtige tilføjelse fra dit forslag er -i der gør at redigering
foregår in-line i filen og ikke bare skriver resultatet til
stdout. GNU sed har i lang tid understøttet en tilsvarende -i, men jeg
ved ikke med andre sed-implementationer så jeg holder mig til perl.

-- 
 Peter Makholm     |               Vi smider blade allesammen - hele tiden
 sslug@sslug |                      som et konstant spirende efterår
 http://hacking.dk |                 Og hele tiden vokser nye frugter frem
                   |                  og vi finder nogen til at plukke dem
                   |                            -- Tilt, Perkussive popler


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2006-04-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] *