views:

50

answers:

3

There are a lot of directories named like

web001
web002
...
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

+1  A: 
ls | sort | tail -n 1

Will tell you what the last folder sorted alphabetically is

Jeffrey Aylesworth
it becomes a wholename. I must extract a number yet. But thanks!
Vov4ik
+2  A: 

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.

jk
+1  A: 

If you want just the number:

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

Nicolas Buduroi
yeah, it does what I want, but with a little changes:`find /path/to/find -type d -name "web*" | sort | tail -n 1 | cut -d'b' -f2`
Vov4ik