1

alias s2st="ps -A | grep -E "a|b"" works for bash.

Then I tried to convert it for csh:

set-alias t2st 'ps -A \| grep -E "a\|b"'

But csh does quoting so different, I couldn't coupe with...

How does it need to be, to be correct and working?

3

In bash, that should be:

alias s2st='ps -A | grep -E "a|b"'

(alias s2st="ps -A | grep -E "a|b"" would not work in bash, as the second " would close the first " so the second | would not be quoted).

In csh

alias s2st 'ps -A | grep -E "a|b"'

Strong quotes in both bash and csh are '...'. They are less strong in csh though where ! and newline (and backslash when preceding those) are still special.

In TCL, strong quotes are {...} with the added benefit that { and } can occur within them as long as they are matched.

  • Thanks! Ok, then my problem isn't csh, but tcl, which I expected to use the same syntax. How should it look like for tcl? – jwk Mar 27 at 12:42
  • 2
    @jwk Your question does not mention tcl. Could you maybe update the question? – Kusalananda Mar 27 at 12:47
1

Thanks to Stéphane Chazelas, I found my problem:

My alias is stored in a tcl script, so I need the correct tcl syntax, which is:

set-alias s2st {ps -A | grep -E "a|b"}
  • 2
    For clarity, the question and answer would benefit from showing a bit more context around how you use the shell and tcl. At the moment, the tcl bit seems to be quite important even though it's barely mentioned in the question. – Kusalananda Mar 27 at 15:12
0

In Tcl I'd write

proc psgrep {pattern} {
    return [join [lsearch -regexp -inline -all [split [exec ps -A] \n] $pattern] \n]
}

set output [psgrep {a|b}]
  • But I don't think this is really what you're asking. – glenn jackman Mar 27 at 15:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.