Deutsch English Français Italiano |
<v5bu70$vaas$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.unix.shell Subject: Re: Is 'ls -v' the Final Solution? (Was: Numerically sorted arguments (in shell)) Date: Mon, 24 Jun 2024 16:01:03 +0200 Organization: A noiseless patient Spider Lines: 59 Message-ID: <v5bu70$vaas$1@dont-email.me> References: <v4grk8$2pp51$1@dont-email.me> <v4us5u$21bu3$1@dont-email.me> <v4vqib$21g0v$1@dont-email.me> <7cbgkkx149.ln2@slack15-a.local.uk> <v5bruk$2kl97$1@news.xmission.com> MIME-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Injection-Date: Mon, 24 Jun 2024 16:01:04 +0200 (CEST) Injection-Info: dont-email.me; posting-host="41527c1e8b8737ff56f892523a11e944"; logging-data="1026396"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cvh13EODcVLnMx4q5sDui" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:1nUBZFCpN0i6OPbCfEwPikvdGXI= In-Reply-To: <v5bruk$2kl97$1@news.xmission.com> X-Enigmail-Draft-Status: N1110 Bytes: 2899 On 24.06.2024 15:22, Kenny McCormack wrote: > In article <7cbgkkx149.ln2@slack15-a.local.uk>, > ... >>> I finally remembered which tool has "versionsort(3)" -- it's ls: >>> >>> $ ls -1 >>> test10.txt >>> test1.txt >>> test2.txt >>> >>> $ ls -v -1 >>> test1.txt >>> test2.txt >>> test10.txt >>> >>> Does that help? >>> >> >> I didn't realise it could work like that. Thanks. > > To OP: Does "ls -v" meet your criteria? Yes, at least partly. (Why are you asking?) It meets it in the way that it's ready available and usable as external command. It does not solve the shell internal additional globbing feature (like in Zsh) that would be nice and preferable. In the quoted form as 'ls -vQ' some pathological filenames are (seemingly) handled, but there's some hassle with the quotes in the subsequent processing steps to expect (or so I think). That's why an integrated form supported by shell would IMO be an advantage; so that we could simply write set -o numsortglob # <-- hypothetical shell feature for f in version*.gz do ... done At least the output from code like for f in $(ls -vQ) ; do printf "'%s'\n" "$f" ; done or ls -vQ | while IFS= read -r f ; do printf "'%s'\n" "$f" ; done indicates that there's still something to do, and without the 'ls -Q' quotes the (pathological) newlines are an issue (at least). I think it's a typical problem that would best be solved by a shell built-in feature. (External tools may take you part of the road and probably with additional effort for common subsets of the task but probably not bullet-proof.) Janis