开发者

Sorting and extracting of dirnames

There are a lot of directories named like

web001

web开发者_运维技巧002

...

web123

...

I want to extract a max-number from this set...

Something like num="´find -name /dirname sort ... | tail´" with extracting. I have no ideas...

Thank you


You can use tr -dc [0-9] to get rid of all non-numbers. Note that this also gets rid of the newline but if you extract just a single line with tail, that does not matter.


If you want just the number:

find -type d -name web\* | sort | tail -n 1 | cut -d'b' -f2


ls | sort | tail -n 1

Will tell you what the last folder sorted alphabetically is

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜