Liste des Groupes | Revenir à cu shell |
On 19.06.2024 17:06, Chris Elvidge wrote:Originally you said:On 19/06/2024 at 14:11, Janis Papanagnou wrote:Yes. Above is just a codified version of the method I described>[...]>
I tried the approach I outlined above... (here just echo'ing the
created parts)...
>
>
N=${1:-1}
sed_a="[^0-9]*\([0-9]\+\)[^0-9]*"
sed_r="\1\t"
sort_a="-k1n"
for (( n=2; n<=N; n++ ))
do
sed_a+="\([0-9]\+\)[^0-9]*"
sed_r+="\${n}\t"
sort_a+=" -k${n}n"
done
cut_a="-f$((N+1))-"
>
echo "# The following commands would be connected by pipes:"
echo "sed 's/${sed_a}/${sed_r}&/'"
echo "sort -t$'\t' ${sort_a}"
echo "cut ${cut_a}"
>
Your way is still restricted to filenames with a known number of sets of
digits, though (AFAICS). I.e. you pass N rather than finding it.
(thus also the echo's). Whether it's provided as parameter N or
obtained, say, from one of the files is left unanswered. Myself
I'd prefer some solution where even file sets with mixed amounts
of numerical parts may be used; thus being able to handle lists
that are named like chapters, like 1, 1.1, 1.2, ..., 5.3.3
Slowly and continuously approaching the goal... :-)
Janis
[...]
Les messages affichés proviennent d'usenet.