help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loop with files coming through sorted by name


From: Daniel Mills
Subject: Re: Loop with files coming through sorted by name
Date: Mon, 18 Oct 2021 17:32:42 -0400

On Sat, Oct 16, 2021 at 10:10 PM tolugboji <tolugboji@protonmail.com> wrote:

>
>
>    nf=$( echo "$fnam" | awk -F '-' '{print NF}')
>    ifld=$(( nf + 1 ))
>
>
>
if you're using NF like this, you don't want to add 1, you're ending up
with a value that's too high. I wouldn't get awk involved here, just do
nf=${fname//[!-]}; ifld=$((${#nf}+1)). Much faster.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]