How to do command substitution à la Bash in Eshell, and not just for loops? (Unfortunately, while this question asks my question, its answer only provides Eshell for
-loop syntax. So please don't dupe me with that: I seek an answer to the general question, using the example below.) FWIW,
- I'm a longtime Basher trying to learn Eshell. I like to think I'm Bash-strong (at least, I've been using it forever both at commandline and for scripts) but ...
- ... I know I'm Elisp-weak. I've adapted or written a few functions for my
init.el
and do someC-u M-:
in buffers, but that's about it. - I'm running Emacs on a Linux.
For this usecase, I want to look at all the *Office docs in a particular filetree
- sorted by time (required)
- in a Dired buffer (preferred)
Let the filetree root=~/foo/bar/
. I can satisfy condition 2 with find-name-dired
, but not condition 1: when I do
M-x find-name-dired ~/foo/bar/ *.odt
and then press s
in the resulting buffer, I get the error
Cannot sort this Dired buffer
So I think, "I know how to do this in Bash. Perhaps if I do it in Eshell, that will give me a Dired buffer?" So I do
M-x eshell
but get
Welcome to the Emacs shell
~/foo/bar $ ls -alt $(find . -name '*.odt')
Invalid read syntax: ". in wrong context"
I assume that's a Lispism, and instead try
~/foo/bar $ ls -alt $(find ./ -name '*.odt')
Invalid read syntax: ")"
I've tried escaping the {parentheses, round brackets} various ways, and even backticks (note to reader--don't use backticks :-) to no avail: I either get the Invalid read syntax: ")"
or more catastrophic errors. I then tried various sorts of C-h
and websearch, without success. What am I doing wrong, and how to fix?