Re: inserting line breals
Michael Marsh wrote:
On 9/5/07, Nathan <firstname.lastname@example.org> wrote:
I've found a perl script on the 'Net that does a very good job of
recursively searching a directory of sub-directories and files. I pipe
the output to the 'mail' program and email it to myself. However it
would help the readability of the text if I could add an extra line
break (carriage return) to each existing line break. Effectively I
would to double-space it.
I am not a perl guru in any shape or form. Can anyone offer suggestions
on the best way to go about this? Thanks.
The following one-liner should do it (it works for me):
perl -pe '$_ .= "\n"' <filename>
You could also do the following:
perl -pi.bak -e '$_ .= "\n"' <filename>
<filename> will now contain the double-spaced text, and <filename>.bak
will contain the original file.
Here's how it works:
"-p" uses an implicit
with "# foo" replaced by your provided script. "-e" specifies that
the next string is the script to run. "-i.bak" says to do in-line
replacement, moving the original to a file with ".bak" as the
extension. You could use any extension you like here.
Since $_ will be printed automatically, we append (".=") a newline to it.
That seems to do the trick, however I'm finding that it isn't matching
when I do a case insensitive search for something that isn't a complete
word. For example a user name of " nathan " or " Nathan " works. But
DOMAIN\Nathan gets skipped.
How can I fix that? Thanks for all of the help!