Faster CR -> LF Macro?
Greg Edwards
gedwards2 at gmail.com
Wed Mar 19 09:02:32 CET 2008
Hi,
I do this sort of stuff in Perl, it's very robust about line-ending hacking.
Try the script below.
Greg.
#!/bin/bash
# Translate any of LF, CR, CRLF to LF.
if [ "$1" == "" ] ; then
echo "Usage: `basename $0` filename"
exit 1
fi
for F in $*
do
echo Converting $F
cat $F | perl -p -e 's/(\r|\n|\r\n)/\n/g' > $F.crlf
mv $F.crlf $F
done
On 19/03/2008, Aaron Hsu <arcfide at mac.com> wrote:
>
> Hello All,
>
> Do any of you have a faster way of doing a CR->LF conversion?
>
> Right now I am using a macro. I want to be able to do this in one shot
> easily, because I do this a lot. Right now I have:
>
> pos = search("\r", 0, "regex")
> while (pos >= 0) {
> replace_range(pos, $search_end, "\n")
> pos = search("\r", 0, "regex")
> }
>
> This is a bit slow because it is running through a macro, so I was
> thinking about making it a script, but I don't know if that would be
> better or not. :-/ I mean, it's nice to have the macro going without
> having to have an external program to run it through.
>
> Just wondering.
>
>
> --
> Aaron Hsu <arcfide at sacrideo.us> | Jabber: arcfide at jabber.org
> ``Government is the great fiction through which everybody endeavors to
> live at the expense of everybody else.'' - Frederic Bastiat
>
> --
> NEdit Discuss mailing list - Discuss at nedit.org
> http://www.nedit.org/mailman/listinfo/discuss
>
>
>
--
Greg Edwards
mob 0400 102 774
More information about the Discuss
mailing list