Hello all,
I have an out put of
ls -l
as follow :
drwxr-xr-x 3 pipeline pipeline 4096 Jun 15 2011 mongodb-linux-x86_64-1.8.2
drwxr-xr-x 3 root root 4096 Feb 27 2012 mongodb-linux-x86_64-2.0.3
now i would like to get 2.0.3
i have tred this and it did not work
ls -l /path |cut -f10 -d" "|cut -f4 -d "-"
do you have any other solution?
Thanks,
rdrtx1
2
try:
ls -l /path | tail -1 | sed 's/.*[-]//'
1 Like
In some hosts i have this kind of output
drwxr-xr-x 3 root root 4096 Sep 23 2010 mongodb-linux-x86_64-1.6.3
drwxr-xr-x 3 root root 4096 Feb 10 2012 mongodb-linux-x86_64-1.8.2
-rw-r--r-- 1 root root 0 Aug 8 2011 velocity.log
now if i would like to disregard the last line and just get the last number( in this case 1.8.2) what should I do?
Thanks,
rdrtx1
4
try:
ls -l /path | grep "[-][0-9]" | tail -1 | sed 's/.*[-]//'
1 Like
Thank you this works perfect!