1
I am trying to find files that match time=*
and then need to display it by sorting it numerically.
The result file names would be :
first/path/time=001.jpg
first/path/time=002.jpg
second/path/time=001.jpg
...
which I want to see as,
first/path/time=001.jpg
second/path/time=001.jpg
first/path/time=002.jpg
...
sorted numerically with respect to the 3 digits on file name.
For now, i tried
find . -name time=* | rev | sort | rev
which does work for single digits but with numbers like 019
021
it does not work.
Full path would be something like,
path/to/folder1/alpha=0.1_beta=0.2_gamma=1.0/time=001.jpg
path/to/folder1/alpha=0.1_beta=0.2_gamma=0.1/time=001.jpg
path/to/folder2/alpha=0.1_beta=0.2_gamma=0.1/time=001.jpg
.
.
.
I think it would be easiest if the files could be sorted using only last 7 characters. 001.jpg
010.jpg
... however sadly sort
does not support support negative indexing to get last 6 characters :(
1
(1) What OS? Looks like some Unix, still you should make it clear. (2) Quote the pattern, or else...
– Kamil Maciorowski – 2018-01-23T10:23:42.270hey, Its Linux and what do you mean by quote the pattern? – hadi k – 2018-01-23T10:29:49.153
I mean exactly what my answer says under this link I have already gave you.
– Kamil Maciorowski – 2018-01-23T10:31:53.123hi thanks, but that was not the problem with me. I dont have
time=*
file in current directory to have that problem. But definitely a new thing to learn! thanks again! i will keep this in find for future. – hadi k – 2018-01-23T11:45:19.673@KamilMaciorowski oh no. i just meant
time=001.jpg
time=002.jpg
and so on. – hadi k – 2018-01-23T13:57:14.790