日期:2014-05-16 浏览次数:20823 次
#!/bin/bash
a="/home/.../..../version/version_20131128100829.ini"
echo ${a:31:45}
echo /home/.../..../version/version_20131128100829.ini
------解决方案--------------------
sed 's/.*_//;s/....$//'
echo /home/.../..../version/version_20131128100829.ini
------解决方案--------------------
sed -r 's/.*_//;s/[^0-9]+$//'
echo /home/.../..../version/version_20131128100829.ini
------解决方案--------------------
sed -r 's/.*_([0-9]+).*/\1/'
echo /home/.../..../version/version_20131128100829.ini
------解决方案--------------------
awk -F_ '{gsub(/[^0-9]/,"",$NF);print $NF}'
basename /home/.../..../version/version_20131128100829.ini
------解决方案--------------------
cut -d "_" -f 2
------解决方案--------------------
cut -d "." -f 1
str="/home/.../..../version/version_20131128100829.ini"; str=${str#*_}; echo ${str%.ini}