OT: scripting, removing trailing ^L
Fairlight
fairlite at fairlite.com
Fri Dec 23 08:48:12 PST 2005
Simon--er, no...it was William James McEachran--said:
> Slightly off-topic.
> The data comes from filePro, some of it passes thru 'gnuplot', and in
> the end the gnuplot graph is incorporated into the filepro output form.
> The whole thing then is converted with 'pcl6'/ghostpcl into a PDF file
> Result, a PDF file with data & a graph.
>
> gnuplot adds an unneed "^L" to the end of the graph pcl file. I've got
> to come up with a way to remove just this one character at the end of the
> file. I've got a mental block on removing just the final character.
>
> sed? awk?
#!/usr/bin/perl
binmode(STDIN);
my (@lines);
@lines = <STDIN>;
$lines[scalar(@lines)-1] =~ s/\014(\r?\n?)$/$1/;
print(@lines);
exit;
##### END OF PROGRAM
This removes -only- the -last- FF present on the last 'line' of output, and
preserves any CRLF or LF at the end of that line. This will work fine on a
binary file, and nothing else is touched. Works on 'doze or *nix.
It's meant to be run in a pipeline as written:
original_generator | gnuplot | this_filterff | whatever_else
If you wanted it to work on a file from the filesystem or store to a
specific place, it's a trivial change to make. Just ask and specify
exactly what you need.
Merry Christmas!
mark->
More information about the Filepro-list
mailing list