Zeilenumbrüche entfernen per Batch

  • #1
C

chrroe

Guest
Hallo Leute!

Ich suche für folgende Aufgabe eine Lösung:
Aus einer (Text-)datei sollen per Batch (also ohne Benutzerinteraktion) die Zeilenumbrüche entfernt werden bzw. durch ein Leerzeichen ersetzt werden.

Also, aus ...

----
Dies ist Zeile 1
Dies ist Zeile 2
----

... soll ...

----
Dies ist Zeile 1 Dies ist Zeile 2
----

werden.


Wer hat da eine Idee?

Ciao
 
  • #2
kannst du mit awk, sed oder perl für windows erledigen. hier ein beispiel mit perl

#! perl

# Store on screen help text in a variable
$syntax = \nCrLf.pl, Version 1.00\n;
$syntax = $syntax.Replace CR/LF pairs (0D0Ax) with linefeeds only (0Ax)\n\n;
$syntax = $syntax.Usage: CRLF2LF.PL [ infile [ outfile ] ]\n;
$syntax = $syntax.or: any_command | PERL.EXE CRLF2LF.PL > outfile\n;
$syntax = $syntax.or: CRLF2LF.PL /?\n\n;
$syntax = $syntax.Where: \any_command\ is a command that's standard output is used\n;
$syntax = $syntax. instead of \infile\\n;
$syntax = $syntax. \infile\ is an ASCII file with improper line terminations\n;
$syntax = $syntax. (default: standard input)\n;
$syntax = $syntax. \outfile\ is the corrected ASCII file\n;
$syntax = $syntax. (default: standard output)\n\n;
$syntax = $syntax.Written by Rob van der Woude\n;
$syntax = $syntax.

# Help required?
if ( @ARGV[0] eq /? ) {
die $syntax;
}

# Use source file as standard input if specified
if ( @ARGV[0] ) {
open( STDIN, < @ARGV[0] ) || die Cannot open file @ARGV[0]:\n$!\n\n$syntax;
}

# Use target file as standard output if specified
if ( @ARGV[1] ) {
open( STDOUT, > @ARGV[1] ) || die Cannot open file @ARGV[1]:\n$!\n\n$syntax;
}

# Switch to binary mode
binmode( STDIN );
binmode( STDOUT );

# Search and replace standard input and write to standard output
while ( <STDIN> ) {
$line = $_;
$line =~ s/\015\012/\012/g;
print $line;
}

# Close file handles
close( STDIN );
close( STDOUT );

gefunden hier

greetz

hugo
 
Thema:

Zeilenumbrüche entfernen per Batch

ANGEBOTE & SPONSOREN

Statistik des Forums

Themen
113.840
Beiträge
707.966
Mitglieder
51.494
Neuestes Mitglied
Flensburg45
Oben