- 字符串var=http://www.aaa.com/root/123.htm
- 1.取出www.aaa.com/root/123.htm
- 2.取出123.htm
- 3.取出http://www.aaa.com/root
- 4.取出http:
- 5.取出http://
- 6.取出www.aaa.com/root/123.htm
- 7.取出123
- 8.取出123.htm
0
- 1、
- echo "var=http://www.aaa.com/root/123.htm"|awk -F'//' '{print $2}'
- 2、
- echo "var=http://www.aaa.com/root/123.htm"|awk -F'/' '{print $NF}'
- 3、
- 4、
- echo "var=http://www.aaa.com/root/123.htm"|awk -F'=|/' '{print $2}'
- 5、
- 6、
- echo "var=http://www.aaa.com/root/123.htm"|awk -F'//' '{print $2}'
- 7、
- echo "var=http://www.aaa.com/root/123.htm"|awk -F'/' '{print $NF}'|awk -F'.' '{print $1}'
- 8、
- echo "var=http://www.aaa.com/root/123.htm"|awk -F'/' '{print $NF}'
0
- 1、echo "var=http://www.aaa.com/root/123.htm" |awk -F// '{print $2}'
- 2、 echo "var=http://www.aaa.com/root/123.htm" |awk -F/ '{print $5}'
- 3、echo "var=http://www.aaa.com/root/123.htm" | awk -F= '{print $2}' | cut -d"/" -f1-4
- 4、echo "var=http://www.aaa.com/root/123.htm" |awk -F"[0-9]" '{print $1}' | cut -d"=" -f2
- 5、echo "var=http://www.aaa.com/root/123.htm" | awk -F. '{print $1}' | cut -d= -f2 |cut -d"w" -f1
- 6、echo "var=http://www.aaa.com/root/123.htm" |awk -F// '{print $2}'
- 7、echo "var=http://www.aaa.com/root/123.htm" |awk -F. '{print $3}' | cut -d"/" -f3
- 8、echo "var=http://www.aaa.com/root/123.htm" |awk -F/ '{print $5}'
0
本帖最后由 duyanbin 于 2016-4-9 07:25 编辑
var="http://www.aaa.com/root/123.htm"
1.
echo $var | awk -F"//" '{print $2}'
echo $var | grep -o "www.*"
echo ${var#*//}
2.
echo $var | awk -F"/" '{print $5}'
echo $var | grep -o "[0-9]*\.htm"
echo ${var##*/}
3.
echo $var | sed 's|\(.*//.*/.*\)\(/.*\)|\1|'
echo $var | grep -o http.*root
echo ${var%/*}
4.
echo $var | awk -F '//' '{print $1}'
echo $var | sed 's/\/\/www.*//'
echo ${var%%//*}
5.
echo $var | awk -F "w" '{print $1}'
echo $var | sed 's/www.*//'
echo ${var%%w*}
6.
echo $var | awk -F '//' '{print $2}'
echo $var | sed 's|http://||'
echo ${var#*//}
7.
echo $var | tr -c -d '0-9\n'
echo $var | grep -o '[0-9]\{3\}'
var="http://www.aaa.com/root/123.htm"
1.
echo $var | awk -F"//" '{print $2}'
echo $var | grep -o "www.*"
echo ${var#*//}
2.
echo $var | awk -F"/" '{print $5}'
echo $var | grep -o "[0-9]*\.htm"
echo ${var##*/}
3.
echo $var | sed 's|\(.*//.*/.*\)\(/.*\)|\1|'
echo $var | grep -o http.*root
echo ${var%/*}
4.
echo $var | awk -F '//' '{print $1}'
echo $var | sed 's/\/\/www.*//'
echo ${var%%//*}
5.
echo $var | awk -F "w" '{print $1}'
echo $var | sed 's/www.*//'
echo ${var%%w*}
6.
echo $var | awk -F '//' '{print $2}'
echo $var | sed 's|http://||'
echo ${var#*//}
7.
echo $var | tr -c -d '0-9\n'
echo $var | grep -o '[0-9]\{3\}'
编辑回复