re: shell editor

2017-09-26 Thread Linux for blind general discussion
No, fmt is not the same as fold.  The fmt command in my testing failed to 
break lines but fold got the line breaks correct.
Also, truncate is back along with the tr command to change those binary 
zeros to spaces.  Easier approach.  This one so far as I can tell now 
works.  I'll put a loop in the script and a math test on the edited file 
to ensure character limit entered by user is not exceeded in a little 
while.

Cut here.

#!/usr/bin/env bash
# file: fcl.sh - file with character limit script.
echo -c "character limit for file:"
read
lim=$REPLY
echo -c "file name to edit"
read
ef=$REPLY
truncate -s $lim $ef
tr "\0" "." < $ef > $ef.f
mv $ef.f $ef
fold -80 < $ef > $ef.f
mv $ef.f $ef
echo "remember only change lines in $ef to stay inside character limits."
nano $ef
wc -c $ef

--

___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list


Re: shell editor

2017-09-26 Thread Linux for blind general discussion
Potential problem with dd is it requires an input file and the first 
creation of the file will be an append operation.  I'll try using 
/dev/null for input and converting all output to spaces when this one 
gets created and it's possible this will work.


On Tue, 26 Sep 2017, Linux for blind general discussion wrote:


Date: Tue, 26 Sep 2017 07:01:52
From: Linux for blind general discussion <blinux-list@redhat.com>
To: Linux for blind general discussion <blinux-list@redhat.com>
Subject: Re: shell editor

Thanks, those binary zeros in that context could cause a real mess.
On Tue, 26 Sep 2017, Linux for blind general discussion wrote:


Date: Tue, 26 Sep 2017 00:10:43
From: Linux for blind general discussion <blinux-list@redhat.com>
To: Linux for blind general discussion <blinux-list@redhat.com>
Subject: Re: shell editor

The truncate command will likely have an undesired side-effect: if the
file is smaller than the target size, it will be generally be padded with
binary zeroes to force it to be the specified size.

If pure truncation is desired, might I suggest the dd command instead:
 dd if=input-file of=output-file bs=maxlength count=1
If the input-file is shorter than maxlength, output-file will be the
same as input-file (not padded to maxlength).
(warning: maxlength has a limit, but that limit is usually at least 100 
Meg.)


On Mon, Sep 25, 2017 at 18:07:24PM -0400, Linux for blind general 
discussion wrote:

This isn't what was requested, but I'm pretty certain it will be useful
nonetheless.  The truncate command can create a file and make it a
specific number of characters in size.  Truncation happens from the end of
the file if too large.  So truncate 1 file.txt would make a file 1
characters in length.  Editing that file in overwrite mode not insert mode
change lines don't insert lines would use up the space for the character
limit on the file.  Saving an edit; then truncating the file again but to
a different file name than the original then comm -2 file1 file2 would
show lines only in file2 not in file1.


___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list






--

___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list


Re: shell editor

2017-09-26 Thread Linux for blind general discussion

Thanks, those binary zeros in that context could cause a real mess.
On Tue, 
26 Sep 2017, Linux for blind general discussion wrote:



Date: Tue, 26 Sep 2017 00:10:43
From: Linux for blind general discussion <blinux-list@redhat.com>
To: Linux for blind general discussion <blinux-list@redhat.com>
Subject: Re: shell editor

The truncate command will likely have an undesired side-effect: if the
file is smaller than the target size, it will be generally be padded with
binary zeroes to force it to be the specified size.

If pure truncation is desired, might I suggest the dd command instead:
 dd if=input-file of=output-file bs=maxlength count=1
If the input-file is shorter than maxlength, output-file will be the
same as input-file (not padded to maxlength).
(warning: maxlength has a limit, but that limit is usually at least 100 Meg.)

On Mon, Sep 25, 2017 at 18:07:24PM -0400, Linux for blind general discussion 
wrote:

This isn't what was requested, but I'm pretty certain it will be useful
nonetheless.  The truncate command can create a file and make it a
specific number of characters in size.  Truncation happens from the end of
the file if too large.  So truncate 1 file.txt would make a file 1
characters in length.  Editing that file in overwrite mode not insert mode
change lines don't insert lines would use up the space for the character
limit on the file.  Saving an edit; then truncating the file again but to
a different file name than the original then comm -2 file1 file2 would
show lines only in file2 not in file1.


___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list



--

___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list


Re: shell editor

2017-09-25 Thread Linux for blind general discussion
The truncate command will likely have an undesired side-effect: if the
file is smaller than the target size, it will be generally be padded with
binary zeroes to force it to be the specified size.

If pure truncation is desired, might I suggest the dd command instead:
  dd if=input-file of=output-file bs=maxlength count=1
If the input-file is shorter than maxlength, output-file will be the
same as input-file (not padded to maxlength).
(warning: maxlength has a limit, but that limit is usually at least 100 Meg.)

On Mon, Sep 25, 2017 at 18:07:24PM -0400, Linux for blind general discussion 
wrote:
> This isn't what was requested, but I'm pretty certain it will be useful 
> nonetheless.  The truncate command can create a file and make it a 
> specific number of characters in size.  Truncation happens from the end of 
> the file if too large.  So truncate 1 file.txt would make a file 1 
> characters in length.  Editing that file in overwrite mode not insert mode 
> change lines don't insert lines would use up the space for the character 
> limit on the file.  Saving an edit; then truncating the file again but to 
> a different file name than the original then comm -2 file1 file2 would 
> show lines only in file2 not in file1.

___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list


re: shell editor

2017-09-25 Thread Linux for blind general discussion
This isn't what was requested, but I'm pretty certain it will be useful 
nonetheless.  The truncate command can create a file and make it a 
specific number of characters in size.  Truncation happens from the end of 
the file if too large.  So truncate 1 file.txt would make a file 1 
characters in length.  Editing that file in overwrite mode not insert mode 
change lines don't insert lines would use up the space for the character 
limit on the file.  Saving an edit; then truncating the file again but to 
a different file name than the original then comm -2 file1 file2 would 
show lines only in file2 not in file1.




--

___
Blinux-list mailing list
Blinux-list@redhat.com
https://www.redhat.com/mailman/listinfo/blinux-list