Re: Remove file resulting from ls|tail -1
Dear Oscar,
what a surprising name…
OECT T wrote:
> I need to delete the file resulting from: ls | tail -1
In Bash, $(command) is replaced with the output of "command". For
example,
$ touch $(seq 1 4)
will create files 1, 2, 3 and 4. So you likely want something like
$ rm -i "$(ls | tail -1)"
where the "-i" is for interactive mode (rm will ask you) and the
quotation marks are such that this is treated as a single argument
rather than many different ones.
Note that you might also want to think of passing ls "-1" and and
possibly sort before taking the tail.
Best,
Claudius
--
Please don’t CC me.
Reply to: