• Re: Using terminal commands - corner cases

    From [email protected]@21:1/5 to Richard Owlett on Wed Nov 27 13:00:01 2024
    On Wed, Nov 27, 2024 at 05:38:30AM -0600, Richard Owlett wrote:
    I've used terminal commands for so many decades I don't know where to look
    up fine details of a specific commands.

    I just tried to use the cd command with a target directory having spaces in it's name. Of course the system responded
    > bash: cd: too many arguments

    DuckDuckGo led to [ https://bash.cyberciti.biz/guide/Cd_command#Dealing_with_directories_with_white_space_in_their_names
    ].

    Problem solved. But is there somewhere to go directly without a web search?

    First: cd is not a command, it is a shell builtin
    (this is subtle, but important).

    Second: even if cd were a "command", the splitting
    of args at whitespace (among *a lot* of other things)
    is done by the shell before the command has even a
    chance at it.

    So for both reasons, it's not "cd" what you are looking
    at, but your shell.

    You could do worse than having a look at the Bash Guide,
    co-maintained by one of our regulars here. For your case,
    the first chapter [1] seems relevant.

    Cheers

    [1] https://mywiki.wooledge.org/BashGuide/CommandsAndArguments
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZ0cIlwAKCRAFyCz1etHa RnC8AJwI98Y/OM6G3Gm5tTtZmZZpABQkmQCfZ2/Q/xbr/WgrgMQQpSvVOBtzz6M=
    =bcxp
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to All on Wed Nov 27 12:40:01 2024
    I've used terminal commands for so many decades I don't know where to
    look up fine details of a specific commands.

    I just tried to use the cd command with a target directory having spaces
    in it's name. Of course the system responded
    > bash: cd: too many arguments

    DuckDuckGo led to [ https://bash.cyberciti.biz/guide/Cd_command#Dealing_with_directories_with_white_space_in_their_names
    ].

    Problem solved. But is there somewhere to go directly without a web search?

    TIA

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Richard Owlett on Wed Nov 27 14:40:01 2024
    On Wed, Nov 27, 2024 at 07:30:17AM -0600, Richard Owlett wrote:

    [...]

    Thank you. I've seen his site before. I just created a bookmark folder for "Debian Wikis". The first occupant is https://mywiki.wooledge.org .

    Greg's wiki is a jewel. I thank *him* for it.

    I've been a computer *user* for six of my eight decades.
    My only formal background was a one semester intro to programming course as
    a freshman E.E. student.

    [...]

    Now what programming language was this?

    Cheers
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZ0cgbAAKCRAFyCz1etHa RvXnAJ97mrcDTR3ClvjSkbXFfuGyZjsKSQCZAXOJkyimB29b17j5gjmJJ+93M4g=
    =6BP6
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to Eric S Fraga on Wed Nov 27 15:30:01 2024
    On Wed, Nov 27, 2024 at 02:18:02PM +0000, Eric S Fraga wrote:
    And, just for the record, should you want to find out more about
    commands on Linux without leaving your system (i.e. without any
    interaction with the Internet at all), the man command is available to present the manual pages (dates back to when there was an actual manual
    in early unix days) for individual commands, e.g.

    man bash

    which will describe in quite some detail how to use the shell and

    man -k somekeyword

    will allow to search man pages.

    bash itself also has a help system: type "help" :-)

    Good points -- as a tip, turn things around: first try "help foo",
    then "man foo" whenever you don't know whether what you have is
    a builtin or a command.

    And yes, it's a pity there is no common frontend for both.

    Cheers
    --
    t

    -----BEGIN PGP SIGNATURE-----

    iF0EABECAB0WIQRp53liolZD6iXhAoIFyCz1etHaRgUCZ0csoQAKCRAFyCz1etHa RtOEAJ0ULk6C8PFmb7erktWMVfgmd/fmXwCeNNNy/iKPcwzxCcy3DOHKQvSEXJ4=
    =UQam
    -----END PGP SIGNATURE-----

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Eric S Fraga@21:1/5 to All on Wed Nov 27 15:20:01 2024
    And, just for the record, should you want to find out more about
    commands on Linux without leaving your system (i.e. without any
    interaction with the Internet at all), the man command is available to
    present the manual pages (dates back to when there was an actual manual
    in early unix days) for individual commands, e.g.

    man bash

    which will describe in quite some detail how to use the shell and

    man -k somekeyword

    will allow to search man pages.

    bash itself also has a help system: type "help" :-)

    --
    Eric S Fraga via gnus (Emacs 31.0.50 2024-08-16) on Debian 12.6

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to [email protected] on Wed Nov 27 15:50:01 2024
    On 11/27/24 7:36 AM, [email protected] wrote:
    On Wed, Nov 27, 2024 at 07:30:17AM -0600, Richard Owlett wrote:

    [...]

    Thank you. I've seen his site before. I just created a bookmark folder for >> "Debian Wikis". The first occupant is https://mywiki.wooledge.org .

    Greg's wiki is a jewel. I thank *him* for it.

    I've been a computer *user* for six of my eight decades.
    My only formal background was a one semester intro to programming course as >> a freshman E.E. student.

    [...]

    Now what programming language was this?

    CORC/CUPL
    https://en.wikipedia.org/wiki/Cornell_University_Programming_Language

    Dartmouth's BASIC was more popular. But we had better football ;/



    Cheers


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Greg Wooledge@21:1/5 to [email protected] on Wed Nov 27 15:50:01 2024
    On Wed, Nov 27, 2024 at 12:55:10 +0100, [email protected] wrote:
    First: cd is not a command, it is a shell builtin
    (this is subtle, but important).

    It's both. You can even call it a "builtin command".

    Second: even if cd were a "command", the splitting
    of args at whitespace (among *a lot* of other things)
    is done by the shell before the command has even a
    chance at it.

    Yes. The shell *parses* each command you type, and among the steps
    taken by the parser, one of the most basic is tokenizing the input
    into words.

    Given a command like this:

    cd /mnt/c/Program Files

    the tokenizer breaks it into words:

    [cd] [/mnt/c/Program] [Files]

    The first word will be the name of the command to run, and all the
    words after that will be arguments passed to the command.

    If you want "Program Files" to be treated as a single word, then you
    must use quoting. There are several forms, and they're all acceptable:

    cd "/mnt/c/Program Files"
    cd '/mnt/c/Program Files'
    cd /mnt/c/Program\ Files
    cd /mnt/c/"Program Files"

    In all four cases, the tokenizer only sees two words:

    [cd] [/mnt/c/Program Files]

    (A second parsing step is quote removal, which discards the quoting
    characters that were used to aid the tokenization.)

    Also just for the record, bash's tab completion feature is extremely
    helpful. If you type just "cd /mnt/c/Pro" and then press the Tab key,
    it will look at the actual file system and find files or directories
    that match the current partial word. If there's only one match, then
    it'll type out the rest of the filename for you. If there are multiple matches, the behavior depends on your settings. You may need to press
    Tab a second time to get a list of the matches, so that you can type
    more characters to make your partial word have only a single match.

    When tab completion auto-types a filename with whitespace in it, it'll
    use the backslash quoting form to mark the spaces as literal characters
    rather than word separators.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Joe@21:1/5 to [email protected] on Wed Nov 27 15:50:02 2024
    On Wed, 27 Nov 2024 14:36:44 +0100
    <[email protected]> wrote:

    On Wed, Nov 27, 2024 at 07:30:17AM -0600, Richard Owlett wrote:

    [...]

    Thank you. I've seen his site before. I just created a bookmark
    folder for "Debian Wikis". The first occupant
    is https://mywiki.wooledge.org .

    Greg's wiki is a jewel. I thank *him* for it.

    I've been a computer *user* for six of my eight decades.
    My only formal background was a one semester intro to programming
    course as a freshman E.E. student.

    [...]

    Now what programming language was this?


    I would guess most of us in engineering started with some variant of
    Fortran. Mine was on an ICL1907 mainframe, which I never saw. IBM 80
    column card punches...

    --
    Joe

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Yassine Chaouche@21:1/5 to All on Wed Nov 27 16:40:01 2024
    Le 11/27/24 à 15:18, Eric S Fraga a écrit :
    [...] the man command is available to
    present the manual pages


    There are also the fine info pages for most gnu software,
    notably the coreutils,
    and the /usr/share/doc directory for most other software.

    Best,

    --
    yassine -- sysadm
    +213-779 06 06 23
    http://about.me/ychaouche

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Chris Green@21:1/5 to Eric S Fraga on Wed Nov 27 17:20:01 2024
    Eric S Fraga <[email protected]> wrote:
    And, just for the record, should you want to find out more about
    commands on Linux without leaving your system (i.e. without any
    interaction with the Internet at all), the man command is available to present the manual pages (dates back to when there was an actual manual
    in early unix days) for individual commands, e.g.

    man bash

    which will describe in quite some detail how to use the shell and

    The bash man page is often rather too lengthy to find what one wants
    easily. For bash built-in commands it's often more useful to try
    'help <command>' as you don't then have to wade through the *huge*
    bash man page to find what you want.

    For example 'help cd' gives a nice man page like summary of how to use
    cd.

    --
    Chris Green
    ·

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to Richard Owlett on Thu Nov 28 05:20:01 2024
    On Wed 27 Nov 2024 at 05:38:30 (-0600), Richard Owlett wrote:
    I've used terminal commands for so many decades I don't know where to
    look up fine details of a specific commands.

    I just tried to use the cd command with a target directory having
    spaces in it's name. Of course the system responded
    > bash: cd: too many arguments

    DuckDuckGo led to [ https://bash.cyberciti.biz/guide/Cd_command#Dealing_with_directories_with_white_space_in_their_names
    ].

    Problem solved. But is there somewhere to go directly without a web search?

    Well, it strikes me that, with the exception of Greg's, all these
    posts are about man, info, help, etc., which you probably know
    about already, whereas what your error above shows is that you
    need some passing knowledge of the contents of man bash.

    If you find that rather dry and indigestible, you might try running:

    $ wget http://folk.ntnu.no/geirha/bashguide.pdf

    which gives you a guide that's designed more for reading than
    as a reference document.

    BTW I find large man pages a little more navigable by running, eg:

    $ man -t bash | ps2pdf - /tmp/bash.pdf

    though that might not be suitable for the OP.

    Cheers,
    David.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to David Wright on Thu Nov 28 09:40:01 2024
    On 11/27/24 10:13 PM, David Wright wrote:
    On Wed 27 Nov 2024 at 05:38:30 (-0600), Richard Owlett wrote:
    I've used terminal commands for so many decades I don't know where to
    look up fine details of a specific commands.

    I just tried to use the cd command with a target directory having
    spaces in it's name. Of course the system responded
    > bash: cd: too many arguments

    DuckDuckGo led to [ https://bash.cyberciti.biz/guide/Cd_command#Dealing_with_directories_with_white_space_in_their_names
    ].

    Problem solved. But is there somewhere to go directly without a web search?

    Well, it strikes me that, with the exception of Greg's, all these
    posts are about man, info, help, etc., which you probably know
    about already, whereas what your error above shows is that you
    need some passing knowledge of the contents of man bash.

    If you find that rather dry and indigestible, you might try running:

    $ wget http://folk.ntnu.no/geirha/bashguide.pdf

    Quick browse - looks very interesting, especial the reference links.
    Will read after a night's sleep ;/


    which gives you a guide that's designed more for reading than
    as a reference document.

    BTW I find large man pages a little more navigable by running, eg:

    $ man -t bash | ps2pdf - /tmp/bash.pdf

    though that might not be suitable for the OP.

    Having it in PDF format has some of the convenience I associate wit HTML documents.

    Thank you for both references.



    Cheers,
    David.



    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Erwan David@21:1/5 to Richard Owlett on Thu Nov 28 16:20:01 2024
    On Thu, Nov 28, 2024 at 04:12:05PM CET, Richard Owlett <[email protected]> said:
    On 11/28/24 8:52 AM, Max Nikulin wrote:
    On 28/11/2024 11:13, David Wright wrote:
       $ man -t bash | ps2pdf - /tmp/bash.pdf

    What is the point in converting man when the same content is available
    as texinfo source? Moreover, PDF file is ready to use:

    /usr/share/doc/bash-doc/bash.html
    /usr/share/doc/bash-doc/bash.pdf
    /usr/share/doc/bash-doc/bashref.html
    /usr/share/doc/bash-doc/bashref.pdf
    ??????????????????!
    /usr/share/doc/bash-doc/ does *NOT* exist on my Debian 12.7 machine
    All defaults were accepted during install.

    It is in the bash-doc package, which is optional


    --
    Erwan David

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Owlett@21:1/5 to Max Nikulin on Thu Nov 28 16:20:01 2024
    On 11/28/24 8:52 AM, Max Nikulin wrote:
    On 28/11/2024 11:13, David Wright wrote:
       $ man -t bash | ps2pdf - /tmp/bash.pdf

    What is the point in converting man when the same content is available
    as texinfo source? Moreover, PDF file is ready to use:

    /usr/share/doc/bash-doc/bash.html
    /usr/share/doc/bash-doc/bash.pdf
    /usr/share/doc/bash-doc/bashref.html
    /usr/share/doc/bash-doc/bashref.pdf
    ??????????????????!
    /usr/share/doc/bash-doc/ does *NOT* exist on my Debian 12.7 machine
    All defaults were accepted during install.



    Latest released version is available from <https://www.gnu.org/software/bash/manual/>




    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to Max Nikulin on Fri Nov 29 19:40:02 2024
    On Thu 28 Nov 2024 at 21:52:05 (+0700), Max Nikulin wrote:
    On 28/11/2024 11:13, David Wright wrote:
    $ man -t bash | ps2pdf - /tmp/bash.pdf

    What is the point in converting man when the same content is available
    as texinfo source? Moreover, PDF file is ready to use:

    /usr/share/doc/bash-doc/bash.html
    /usr/share/doc/bash-doc/bash.pdf
    /usr/share/doc/bash-doc/bashref.html
    /usr/share/doc/bash-doc/bashref.pdf

    Latest released version is available from <https://www.gnu.org/software/bash/manual/>

    That Debian supplies a PDF in bash-doc certainly lends
    support to its being a useful format.

    But man-t yields a PDF with your appropriate page size,
    whereas bash-doc has only A4.¹

    Just as cd happened to be the command that triggered
    the OP's problem with quoting, so bash just happens
    to be the man page that's most relevant for answering
    the OP's question.

    But where are the PDF versions of other lengthy manpages,
    like curl, ffmpeg-all, fvwm, gm, mc, mplayer, mpv, rsync,
    etc., depending where you draw the line.

    Perhaps permute fish, give, man, teach, into well-known
    aphorism.

    ¹ With Letter size in xpdf, I press 3 for 200%, which
    gives me exactly two PageDowns per page. Annoyingly,
    A4 needs an extra PageDown to move to the next page.

    Cheers,
    David.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From David Wright@21:1/5 to Max Nikulin on Mon Dec 2 04:00:01 2024
    On Sat 30 Nov 2024 at 22:10:32 (+0700), Max Nikulin wrote:
    On 30/11/2024 01:29, David Wright wrote:
    On Thu 28 Nov 2024 at 21:52:05 (+0700), Max Nikulin wrote:
    On 28/11/2024 11:13, David Wright wrote:
    $ man -t bash | ps2pdf - /tmp/bash.pdf

    /usr/share/doc/bash-doc/bash.pdf
    /usr/share/doc/bash-doc/bashref.pdf

    ¹ With Letter size in xpdf, I press 3 for 200%, which
    gives me exactly two PageDowns per page. Annoyingly,
    A4 needs an extra PageDown to move to the next page.

    You may bind another key to zoom adjusted for A4.

    By "appropriate page size", I was thinking more about people who
    might wish to print the document, rather than this trivial annoyance
    for me. I don't come across that many A4 text documents over here.

    Actually I would
    prefer bashref.pdf that has hyperlinks and table of contents
    (bookmark), moreover I would prefer .info file to read it in tkinfo or
    emacs. PDF file generated through PostScript from man does not allow
    to use named anchors for adding links to notes. Page numbers may
    change in next release of if the file is rendered for another paper
    size.

    That's a different type of document entirely. My comment was aimed
    at /man pages in general/. As I said, man bash was just the example
    that came up. Some other commands have further explanatory documents
    in a variety of formats, but that doesn't reduce the usefulness of
    $ man -t foo | ps2pdf - /tmp/foo.pdf
    does it?

    Funnily enough, I'd never even thought about page numbering in
    connection with man pages. But I notice now that the page contents
    of my Letter PDF and Debian's A4 version are identical, and the
    footers on the A4 are very high, so I'm guessing that the document
    was originally set for Letter paper, with well-balanced margins,
    and the A4 version just had more white space added at the bottom.

    Cheers,
    David.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Michael Paoli@21:1/5 to [email protected] on Mon Dec 2 10:20:01 2024
    From most, shells, e.g. bash, dash, most or all POSIX shells, you can type: type name_of_command
    And it'll generally tell you what/where that command comes from, or if
    it's an alias, etc.
    E.g. from either bash or dash:
    $ type cd
    cd is a shell builtin
    $
    So then you could look it up in the relevant man page.
    In this case, either bash or dash.
    But your issue isn't with cd, but characters special to the shell,
    and how the shell parses commands, and (your lack of) quoting.
    So, read the bash (or dash) man page about that.
    If you want to start somewhat simpler, rather than read the quite length
    bash man page, start with something relevant that it's mostly backwards compatible with, e.g. dash (1224 lines of text, vs. 6021 for bash),
    or POSIX shell: https://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html
    Or even start with ye olde Borne shell from 1979 (a mere 6 pages): https://www.mpaoli.net/~michael/unix/sh/

    So ... not a corner case, but how Bourne and relatively compatible shells
    have generally been parsing commands for well over four decades now.

    On Wed, Nov 27, 2024 at 3:38 AM Richard Owlett <[email protected]> wrote:
    I've used terminal commands for so many decades I don't know where to
    look up fine details of a specific commands.
    I just tried to use the cd command with a target directory having spaces
    in it's name. Of course the system responded
    > bash: cd: too many arguments
    Problem solved. But is there somewhere to go directly without a web search?

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From [email protected]@21:1/5 to David Wright on Mon Dec 2 13:00:01 2024
    David Wright <[email protected]> wrote:

    Funnily enough, I'd never even thought about page numbering in
    connection with man pages. But I notice now that the page contents
    of my Letter PDF and Debian's A4 version are identical, and the
    footers on the A4 are very high, so I'm guessing that the document
    was originally set for Letter paper, with well-balanced margins,
    and the A4 version just had more white space added at the bottom.

    A4 paper is a little longer than LTR but also slightly narrower. So if
    I'm trying to print the same content on both I use the width of A4 and
    the length of LTR to set the margins. (210 x 297 A4, 215.9 x 279.4 LTR)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)