• Re: The angle bracket in an echo command???

    From Kenny McCormack@21:1/5 to [email protected] on Wed Jun 14 19:25:27 2023
    XPost: alt.msdos.batch

    In article <[email protected]>,
    Muhammad Usman <[email protected]> wrote:
    On Saturday, 13 May 2023 at 13:36:03 UTC+5, Kerr-Mudd, John wrote:
    On Fri, 12 May 2023 23:53:16 -0700 (PDT)
    Muhammad Usman <[email protected]> wrote:

    I got the solution just after 26 years. Use single quotes such as
    ... and changing OS.
    echo -e '<!DOCTYPE html>'
    will solve the issue.

    If we use double quotes, it will surely raise an error.
    echo -e "<!DOCTYPE html>"
    ```bash: !DOCTYPE: event not found```
    ...

    I was doing it on bash shell linux. Never tried it on DOS or windows

    Then you posted to the wrong newsgroup.

    Anyway, believe it or not, it is not the angle brackets that are giving you grief (see below - *); rather, it is the exclamation point (!). You need to read up on the topic of "history substitution" in "man bash".

    (*) Basically, either single or double quotes will protect angle brackets,
    but you need single quotes to protect "!".

    --
    Faith doesn't give you the answers; it just stops you from asking the questions.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ivan Shmakov@21:1/5 to All on Thu Jun 15 21:20:42 2023
    XPost: alt.msdos.batch

    On 2023-06-14, Kenny McCormack wrote:
    MU == Muhammad Usman <[email protected]> wrote:

    I got the solution just after 26 years. Use single quotes such as
    echo -e '<!DOCTYPE html>'
    will solve the issue.

    [...]

    Anyway, believe it or not, it is not the angle brackets that are
    giving you grief (see below - *); rather, it is the exclamation point
    (!). You need to read up on the topic of "history substitution" in
    "man bash".

    (*) Basically, either single or double quotes will protect angle
    brackets, but you need single quotes to protect "!".

    It's also possible to disable history substitution altogether
    with 'set +H'.

    I believe this behavior is rather confusing to new users, and
    given that C-r (reverse-search-history) and cursor keys already
    offer a comparable feature, and one likely to fit better with
    user's prior experience at that, my suggestion would be to
    have it disabled by default.

    --
    FSF associate member #7257 http://am-1.org/~ivan/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Ivan Shmakov on Thu Jun 15 23:40:31 2023
    Ivan Shmakov <[email protected]d> writes:

    On 2023-06-14, Kenny McCormack wrote:
    MU == Muhammad Usman <[email protected]> wrote:

    I got the solution just after 26 years. Use single quotes such as
    echo -e '<!DOCTYPE html>'
    will solve the issue.

    [...]

    Anyway, believe it or not, it is not the angle brackets that are
    giving you grief (see below - *); rather, it is the exclamation point
    (!). You need to read up on the topic of "history substitution" in
    "man bash".

    (*) Basically, either single or double quotes will protect angle
    brackets, but you need single quotes to protect "!".

    It's also possible to disable history substitution altogether
    with 'set +H'.

    I believe this behavior is rather confusing to new users, and
    given that C-r (reverse-search-history) and cursor keys already
    offer a comparable feature, and one likely to fit better with
    user's prior experience at that, my suggestion would be to
    have it disabled by default.

    That's been my preference for some time. It was useful decades ago (in
    csh if I recall correctly) but I never want it anymore.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Spiros Bousbouras@21:1/5 to Ben Bacarisse on Fri Jun 16 11:07:53 2023
    On Thu, 15 Jun 2023 23:40:31 +0100
    Ben Bacarisse <[email protected]> wrote:
    Ivan Shmakov <[email protected]d> writes:
    (*) Basically, either single or double quotes will protect angle brackets, but you need single quotes to protect "!".

    It's also possible to disable history substitution altogether
    with 'set +H'.
    [...]
    That's been my preference for some time. It was useful decades ago (in
    csh if I recall correctly) but I never want it anymore.

    I use history substitution all the time. Most often I use !:$ or !:$:h or !:$:t with the $ occasionally replaced by a command number. I've never had to consciously remember any rules regarding how the ! is expanded.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Spiros Bousbouras on Fri Jun 16 15:26:43 2023
    Spiros Bousbouras <[email protected]> writes:

    On Thu, 15 Jun 2023 23:40:31 +0100
    Ben Bacarisse <[email protected]> wrote:
    Ivan Shmakov <[email protected]d> writes:
    (*) Basically, either single or double quotes will protect angle
    brackets, but you need single quotes to protect "!".

    It's also possible to disable history substitution altogether
    with 'set +H'.
    [...]
    That's been my preference for some time. It was useful decades ago (in
    csh if I recall correctly) but I never want it anymore.

    I use history substitution all the time. Most often I use !:$ or !:$:h or !:$:t with the $ occasionally replaced by a command number. I've never had to consciously remember any rules regarding how the ! is expanded.

    I used to use !:$ but Alt-. has taken over. Nothing like a general as
    the !:3:h and so on, but useful enough that I've forgotten the old ways.

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Spiros Bousbouras@21:1/5 to Spiros Bousbouras on Fri Jun 16 15:43:31 2023
    Once upon a time
    Spiros Bousbouras <[email protected]> wrote:
    On Thu, 15 Jun 2023 23:40:31 +0100
    Ben Bacarisse <[email protected]> wrote:
    Ivan Shmakov <[email protected]d> writes:
    (*) Basically, either single or double quotes will protect angle brackets, but you need single quotes to protect "!".

    It's also possible to disable history substitution altogether
    with 'set +H'.
    [...]
    That's been my preference for some time. It was useful decades ago (in
    csh if I recall correctly) but I never want it anymore.

    I use history substitution all the time. Most often I use !:$ or !:$:h or !:$:t with the $ occasionally replaced by a command number. I've never had to consciously remember any rules regarding how the ! is expanded.

    Forgot : there is also the :r modifier and also the variation !-N where N is some number. I also use a lot !prefix which finds the most recent command which starts with prefix and !?string? which finds the most recent command which contains string .

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Axel Reichert@21:1/5 to Ben Bacarisse on Sat Jun 17 10:20:49 2023
    Ben Bacarisse <[email protected]> writes:

    I used to use !:$ but Alt-. has taken over.

    Ah! I did not know that, great, thanks!

    So I can cover

    sudo !!

    with the even shorter (and funny!)

    alias doch='sudo bash -c "$(fc -ln -1)"'

    and

    !$

    with

    M-. (interactive)

    or

    $_ (blind)

    The other two tcsh left-overs, ^ (like in ^sl^ls) and !* are handled by

    alias r='fc -s'

    and

    r sl=ls

    Best regards

    Axel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Janis Papanagnou@21:1/5 to Axel Reichert on Sat Jun 17 11:22:02 2023
    On 17.06.23 10:20, Axel Reichert wrote:

    The other two tcsh left-overs, ^ (like in ^sl^ls) and !* are handled by

    (As the example shows, some typos seem to be quite common. :-)

    r sl=ls

    While I know r and its substitution feature I seem to rarely use it in practice.

    As a vi-mode user in shell I use history editing with the vi emulation
    almost exclusively. For the above case [intuitively] typing '<Esc>kxp'.
    In this case it's shorter, but the 'r x=y' of course works also in more
    complex substitution cases (as the built-in editor emulations also do).

    Therefore I even "waste" some keystrokes at times, instead of a simple 'r<Enter>' I prefer to type '<Esc>k<Enter>'. I obviously avoid special
    cases where a more general, powerful, and efficient option exists. The
    special case implementations are fine if available for for common tasks, especially when you start a new tool.

    I gave up csh's '!' feature very early (when I switched to ksh88) and
    rarely had a case for using ksh's 'r' feature.

    Janis

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Ben Bacarisse@21:1/5 to Benjamin Esham on Sun Jun 18 15:34:54 2023
    Benjamin Esham <[email protected]> writes:

    On the other hand, M-. also seems to work in Zsh, and it's fewer keystrokes than !$<Tab>. I'll try to remember it next time I need this!

    I find M-. so handy that it's influenced my working. I now, almost unconsciously, arrange that the argument I am likely to use soon is
    the last.

    It's a shame that, as far as I know, there is no way to interactively
    cycle round the command arguments. Having found the last argument on
    the command I want, I'd sometimes like to get the next to last and so
    on. M-, maybe? I wonder if it would be worth trying to write such a
    patch...

    --
    Ben.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Benjamin Esham@21:1/5 to Axel Reichert on Sun Jun 18 10:25:15 2023
    Axel Reichert wrote:

    So I can cover [snip]

    !$

    with

    M-. (interactive)

    or

    $_ (blind)

    Zsh supports the csh-style !$ and friends (as long as you have the BANG_HIST option set, which it is by default), but it also allows you to type <Tab>
    after something like !$, in which case it will expand it immediately so that you don't have to run the command blind. (This is especially useful with constructions like !!:3, where I always wonder if I miscounted the words in
    the previous line, or if I'm misremembering whether the counting is zero- or one-based.)

    On the other hand, M-. also seems to work in Zsh, and it's fewer keystrokes than !$<Tab>. I'll try to remember it next time I need this!

    Benjamin

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