• Re: text reformating

    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 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 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 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 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 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)