From: Linux for blind general discussion <blinux-list@redhat.com>
To: Linux for blind general discussion <blinux-list@redhat.com>
Subject: Re: Convert unwrapped paragraphs to hard wrapped paragraphs when there's no blank lines.
Date: Fri, 27 Mar 2020 19:19:06 -0400 [thread overview]
Message-ID: <20200327231906.GA19889@panix.com> (raw)
In-Reply-To: <20200327142702.35209f95@bigbox.attlocal.net>
The following assumes a newline at the end of each paragraph.
The PERL script below will put a blank line after each unwrapped paragraph, which in text is
just one long line terminated with a newline.
Put the perl script in your ~/bin/ directory in a file named doublespace and chmod it to 755.
Next, the following command will break an unwrapped paragraph into 75 character lines:
fold -sbw 75 <file>
Now put the two together:
cat $1 | doublespace | fold -sbw 75
Put the above command into ~/bin/dscat, chmod it to 755
and you can do:
dscat unwrapped_file > double_spaced_file
Now here's the perl script:
#!/usr/local/bin/perl
# Double space the standard input. Expects a text file.
while(<STDIN>)
{
chomp $_;
if ($_ eq "" or $_ =~ /^ *$/)
{
print "\n";
}
else
{
print "$_
";
}
}
On Fri, Mar 27, 2020 at 02:27:02PM -0500, Linux for blind general discussion wrote:
> On March 27, 2020, Linux for blind general discussion wrote:
> > does anyone know a way to automate inserting blank lines before
> > and after each line in a file that's too long to fit on the screen
> > all at once and then hard wrap those long lines?
>
> Well, since adding a blank line after each line-break puts a blank
> line before the next line, you (should?) only need to add newlines
> after each line which can easily be done with sed:
>
> $ sed G input_file.txt > output_file_with_spaces.txt
>
> If you want to format the lines at the same time, you can do that
> with "fmt"
>
> $ sed G input.txt | fmt > formatted_output_with_spaces.txt
>
> By default, fmt formats to 72 characters wide but you can adjust that
> using
>
> fmt -80
>
> Hope this helps,
>
> -tim
>
>
>
> _______________________________________________
> Blinux-list mailing list
> Blinux-list@redhat.com
> https://www.redhat.com/mailman/listinfo/blinux-list
--
Rudy Vener
Website: http://www.rudyvener.com
next prev parent reply other threads:[~ UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
Linux for blind general discussion
` Linux for blind general discussion
` Convert unwrapped paragraphs to hard wrapped paragraphs whenthere's " Linux for blind general discussion
` Linux for blind general discussion
` Linux for blind general discussion
` Convert unwrapped paragraphs to hard wrapped paragraphs when there's " Linux for blind general discussion
` Linux for blind general discussion [this message]
` Linux for blind general discussion
` Convert unwrapped paragraphs to hard wrapped paragraphs when there'sno " Linux for blind general discussion
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200327231906.GA19889@panix.com \
--to=blinux-list@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).