[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: ls head and gv
From: |
Dennis Williamson |
Subject: |
Re: ls head and gv |
Date: |
Fri, 28 Jul 2023 23:03:06 -0500 |
On Fri, Jul 28, 2023, 10:50 PM David Niklas <deference@null.net> wrote:
> I used this command:
> alias lgv="gv "$(ls -c *.pdf | head -n1)" &"
>
> What I expected was the latest pdf document to be brought up in gv and gv
> goes to the background.
> What happens is that a semi-random pdf document is loaded into gv and gv
> goes into the background.
>
> Any ideas?
>
> Thanks,
> David
>
>
Without looking at it any further, my first reaction is to change the outer
quotes to single quotes to defer interpretation of the command
substitution. Otherwise it's evaluated immediately and you'll always get
the same file
Further evaluation might lead to other improvements.
See
https://mywiki.wooledge.org/BashFAQ/099
in the mean time.