🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: ch.comp.os.linux
3 messages
3 total messages Started by Eggenberger Marc Fri, 16 Apr 1999 00:00
replace in datei?
#23051
Author: Eggenberger Marc
Date: Fri, 16 Apr 1999 00:00
16 lines
854 bytes
hi ...

gibt es ein replace in dateien?

also sowas wie s/muster/neues_muster/g in Perl auf textdateien .. dann 
msus ichs nicht noch in perl machen (mann bin ich faul ;) ...)

sowas wie 

freplace muster neues_muster *.txt 

dass mir dann in allen *.txt das muster ersetzt durch neues_muster

-- 
mfg
Eggenberger Marc
Re: replace in datei?
#22913
Author: Peter Keel
Date: Wed, 21 Apr 1999 00:00
45 lines
1952 bytes
In article <MPG.11818707c261d910989696@news.unisource.ch>,
	me@ieo.ch (Eggenberger Marc) writes:
> hi ...
> 
> gibt es ein replace in dateien?
> 
> also sowas wie s/muster/neues_muster/g in Perl auf textdateien .. dann 
> msus ichs nicht noch in perl machen (mann bin ich faul ;) ...)

Sowas wie dasda:

#!/usr/bin/perl
#
# Author: Peter Keel <killer@discordia.ch>
# Changes some string in various textfiles into another. Does not accept
# a string on the commandline because I want to be able to use wildcards
# on the filenames.
#

$string1="main.htm";   # or "�" or "none" or whatever..
$string2="index.html"; # or "ss" or "None" or whatever..

die "Usage: $0 filenames\n"       unless($ARGV[0]);

foreach $file_name (@ARGV) {
    $temp_file="/tmp/$file_name";
    open(IN_FILE,"<$file_name") || die "Cannot open $file_name for input\n";
    open(TEMP,">$temp_file");
    while(<IN_FILE>){
        $_ =~ s/$string1/$string2/g;
        print TEMP ($_);
    }
    close IN;
    close TEMP;
    system ("mv $temp_file $file_name");
}


Mehr solchen Krempel gibts auf 
http://killer.discordia.ch/Unix/Programs/

Peter
-- 
"The more prohibitions there are, The poorer the people will be"
-- Lao Tse  
Re: replace in datei?
#22899
Author: Maechler Albin
Date: Fri, 23 Apr 1999 00:00
7 lines
870 bytes
Eggenberger Marc wrote:
> gibt es ein replace in dateien?

Schau Dir mal http://hpux.csc.liv.ac.uk/hppd/hpux/Users/replace-1.03/ an...


Albin
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads