• text reformating

    From Grant Weasner@1:138/397 to All on Mon May 19 01:24:03 2025
    Hello all.

    I'm wondering what others think about linux a text formating task I'm trying to solve.

    I've got lots of older howtos from the old web, and stuff I've also wrote.

    I want to convert all of my text files in many directories into a gopher fiendly format.

    Gopher friendly:
    1) 64 columns wide.
    2) any indents will remain, but if a line goes beyond 64 cols, the remaining characters will go to the line below but indent to the same column as the prior line.


    This seems pretty difficult and I'm wondering how others would approch this task.

    I'm thinking of just writing a python script using basic python modules.

    But I'm wondering if there are just native linux tools that would work as good or better.

    EXAMPLE TEXT BELOW
    -------------------------------------------------------

    $ ssh skinner "dd if=/dev/sda5 | gzip -1 -" | dd of=image.gz
    208782+0 records in
    208782+0 records out
    106896384 bytes (107 MB) copied, 22.7608 seconds, 4.7 MB/s
    116749+1 records in
    116749+1 records out
    59775805 bytes (60 MB) copied, 23.9154 s, 2.5 MB/s

    $ ll | grep image.gz
    -rw-rw-r--. 1 saml saml 59775805 May 31 01:03 image.gz

    Methods for monitoring?

    11.Login via ssh in another terminal and ls -l the file to see what it's size is.
    22.You can use pv to monitor the progress of a large dd operation, for instance, for the remote example above, you can do:

    $ dd if=/dev/sda | gzip -1 - | pv | ssh user@local dd of=image.gz

    33.Send a "SIGUSR1" signal to dd and it will print stats. Something like:

    $ pkill -USR1 dd
    --- SBBSecho 3.20-Linux
    * Origin: Lunar Outpost - lunarout.synchro.net (1:138/397)
  • From Dan Clough@1:135/115 to Grant Weasner on Mon May 19 08:34:30 2025
    Grant Weasner wrote to All <=-

    Hello all.

    I'm wondering what others think about linux a text formating task I'm trying to solve.

    I've got lots of older howtos from the old web, and stuff I've also
    wrote.

    I want to convert all of my text files in many directories into a
    gopher fiendly format.

    Gopher friendly:
    1) 64 columns wide.
    2) any indents will remain, but if a line goes beyond 64 cols, the remaining characters will go to the line below but indent to the same column as the prior line.


    This seems pretty difficult and I'm wondering how others would approch this task.

    I'm thinking of just writing a python script using basic python
    modules.

    But I'm wondering if there are just native linux tools that would work
    as good or better.

    <SNIP>

    man fold



    ... So easy, a child could do it. Child sold separately.
    === MultiMail/Linux v0.52
    --- SBBSecho 3.25-Linux
    * Origin: Palantir * palantirbbs.ddns.net * Pensacola, FL * (1:135/115)
  • From Grant Weasner@1:138/397 to Dan Clough on Mon May 19 11:48:11 2025
    Re: Re: text reformating
    By: Dan Clough to Grant Weasner on Mon May 19 2025 08:34:30

    Grant Weasner wrote to All <=-

    Hello all.

    I'm wondering what others think about linux a text formating task I'm trying to solve.

    I've got lots of older howtos from the old web, and stuff I've also wrote.

    I want to convert all of my text files in many directories into a gopher fiendly format.

    Gopher friendly:
    1) 64 columns wide.
    2) any indents will remain, but if a line goes beyond 64 cols, the remaining characters will go to the line below but
    indent
    to the same column as the prior line.


    This seems pretty difficult and I'm wondering how others would approch this task.

    I'm thinking of just writing a python script using basic python modules.

    But I'm wondering if there are just native linux tools that would work as good or better.

    <SNIP>

    man fold

    Thanks Dan.

    fold -sw 64 file.txt

    -s = break on spaces
    -w width of text
    ---------------------

    Fold produced pretty good results, and very quick. It does doesn't add indents to the prior linae, but still pretty good.

    I think this will work well. I really was trying to get any break that had an indent on the prior line would have to concatenate the line below then indent every line beolw until it sees a line where there is no indent. This is pretty difficult. Fun project but time consuming.

    The EXAMPLE AFTER text looks more like paragraphs, which is still nice.

    There are some areas of that document that get really mangled where there are two columns of text. I hadn't really though of how to deal with that.

    Something like:
    1) here is a left area of text * here is a right area of text
    2) here is a left area of text * here is a right area of text

    So I think I've added even more complexity. :( :)


    EXAMPLE BEFORE:
    ---------------------------

    # cat /etc/anacrontab
    7 15 test.daily /bin/sh /home/sathiya/backup.sh

    START_HOURS_RANGE and RANDOM_DELAY

    The above example indicates that the backup.sh script should be executed every day, with a delay of 15 mins. i.e When the laptop was started, executed it only after 15 minutes.

    EXAMPLE AFTER:
    ---------------------------

    # cat /etc/anacrontab
    7 15 test.daily /bin/sh /home/sathiya/backup.sh

    START_HOURS_RANGE and RANDOM_DELAY

    The above example indicates that the backup.sh script should
    be executed every day, with a delay of 15 mins. i.e When the
    laptop was started, executed it only after 15 minutes.
    --- SBBSecho 3.20-Linux
    * Origin: Lunar Outpost - lunarout.synchro.net (1:138/397)
  • From Sean Dennis@1:18/200 to Dan Clough on Mon May 19 18:41:09 2025
    Dan Clough wrote to Grant Weasner <=-

    man fold

    fold is an amazing utility. Very helpful with text files.

    When I was publishing th FidoGazette, I used fold a lot in reformatting,

    -- Sean

    ... To the thief who stole my anti-depressants: I hope you're happy.
    --- MultiMail/Win
    * Origin: Outpost BBS * Johnson City, TN (1:18/200)
  • From Nigel Reed@1:124/5016 to All on Mon May 19 21:10:44 2025
    On Mon, 19 May 2025 20:54:16 -0500
    "Dan Clough" (1:135/115) <Dan.Clough@f115.n135.z1.fidonet> wrote:

    Sean Dennis wrote to Dan Clough <=-

    Dan Clough wrote to Grant Weasner <=-

    man fold

    fold is an amazing utility. Very helpful with text files.

    Indeed it is. A classic *nix utility - do one thing, and do it well.

    When I was publishing th FidoGazette, I used fold a lot in
    reformatting,

    Yes, very handy for making "wide" stuff fit on a 80x25 character
    screen. :-)

    So many useful, and maybe not so useful utilities out there.

    paste, will take 2 or more files and put them next to each other, like
    a sideways cat :)

    Talking of cat, there is also tac which will display a file from the
    bottom up.

    ncal is like cat but with the days down the side.

    To randomly shuffle the lines of a text file you can pipe it into shuf

    fmt is another text processor similar to, but different from fold.
    --
    End Of The Line BBS - Plano, TX
    telnet endofthelinebbs.com 23
    --- SBBSecho 3.27-Linux
    * Origin: End Of The Line BBS - endofthelinebbs.com (1:124/5016)
  • From Maurice Kinal@2:280/464.113 to Grant Weasner on Mon May 19 20:33:48 2025
    Hej Grant!

    ----- example.text
    The above example indicates that the backup.sh script should be executed every day, with a delay of 15 mins. i.e When the laptop was started, executed it only after 15 minutes.

    For the above line (paragraph) this will work;

    $ sed 's/^ *//' example.text | fold -sw 61 | sed 's/^/ /'
    The above example indicates that the backup.sh script should
    be executed every day, with a delay of 15 mins. i.e When the
    laptop was started, executed it only after 15 minutes.

    Note that the width is 61 characters before tacking on the indentation of three spaces. Also note that the width is characters ***NOT*** bytes.

    $ trans -b -no-ansi -t ukrainian -i example.text | fold -sw 61 | sed 's/^/ /'
    Наведений вище приклад вказує на те, що сценарій резервного
    копіювання.Sh повинен виконуватись щодня, із затримкою 15
    хвилин. тобто, коли ноутбук був запущений, виконував його
    лише через 15 хвилин.

    If the application you are using to read this is utf8 capable you will note that the translation is still counting 16 bit characters (Cyrillic) as one. To get fold to wrap bytes then add the -b switch to fold since the default is characters. For strictly 7 and 8 bit characters, -b and -c are the same.

    Het leven is goed,
    Maurice

    o- o- -o o-
    /) /) (\ /)
    ^^ ^^ ^^ ^^
    ... þa þurfon swiþe lytles, þe maran ne willniaþ þonne genoges.
    They need very little who desire no more than enough.
    --- GNU bash, version 5.2.37(1)-release (x86_64-pc-linux-gnu)
    * Origin: Little Mikey's EuroPoint @ (2:280/464.113)
  • From Dan Clough@1:135/115 to Sean Dennis on Mon May 19 20:54:16 2025
    Sean Dennis wrote to Dan Clough <=-

    Dan Clough wrote to Grant Weasner <=-

    man fold

    fold is an amazing utility. Very helpful with text files.

    Indeed it is. A classic *nix utility - do one thing, and do it well.

    When I was publishing th FidoGazette, I used fold a lot in
    reformatting,

    Yes, very handy for making "wide" stuff fit on a 80x25 character screen.
    :-)



    ... She kept saying I didn't listen to her, or something like that.
    === MultiMail/Linux v0.52
    --- SBBSecho 3.25-Linux
    * Origin: Palantir * palantirbbs.ddns.net * Pensacola, FL * (1:135/115)
  • From Dan Cross@3:770/100 to Grant Weasner on Wed May 21 00:53:25 2025
    On 19 May 2025 at 01:24a, Grant Weasner pondered and said...

    I want to convert all of my text files in many directories into a gopher fiendly format.

    Gopher friendly:
    1) 64 columns wide.
    2) any indents will remain, but if a line goes beyond 64 cols, the remaining characters will go to the line below but indent to the same column as the prior line.

    This seems pretty difficult and I'm wondering how others would approch this task.

    `fmt` or `par`.

    --- Mystic BBS v1.12 A48 (Linux/64)
    * Origin: Agency BBS | Dunedin, New Zealand | agency.bbs.nz (3:770/100)
  • From Dan Clough@1:135/115 to Nigel Reed on Tue May 20 08:16:35 2025
    Nigel Reed wrote to All <=-

    Dan Clough wrote to Grant Weasner <=-

    man fold

    fold is an amazing utility. Very helpful with text files.

    Indeed it is. A classic *nix utility - do one thing, and do it well.

    When I was publishing th FidoGazette, I used fold a lot in reformatting,

    Yes, very handy for making "wide" stuff fit on a 80x25 character
    screen. :-)

    So many useful, and maybe not so useful utilities out there.

    paste, will take 2 or more files and put them next to each other, like
    a sideways cat :)

    Talking of cat, there is also tac which will display a file from the bottom up.

    ncal is like cat but with the days down the side.

    To randomly shuffle the lines of a text file you can pipe it into shuf

    fmt is another text processor similar to, but different from fold.

    Nice! Didn't know about a couple of those, thanks.



    ... Rehab is for quitters.
    === MultiMail/Linux v0.52
    --- SBBSecho 3.25-Linux
    * Origin: Palantir * palantirbbs.ddns.net * Pensacola, FL * (1:135/115)