首页
IT
登录
6mi
u
盘
搜
搜 索
IT
6-字符串篇
6-字符串篇
xiaoxiao
2021-12-14
20
字符串截取
#!/bin/bash
hostname=
"cat.host_name is cat.super.com"
string=
${hostname:3}
echo
$string
string1=
${hostname%.*}
string2=
${hostname%%.*}
string3=
${hostname#*.*}
echo
$string1
echo
$string2
echo
$string3
exit
0
获取长度
#!/bin/bash
book=
"This is a script's book"
size=
${#book}
size2=$(expr length
"
$book
"
)
echo
$size
echo
$size2
exit
0
流重定向
#!/bin/bash
FROM=
'from:root@cat.super.com'
TO=
'to:cat@cat.super.com'
SUBJECT=
'subject:shell script'
MESSAGE=
'This is bash shell script'
F_NAME=
'linux_shell'
cat >
$F_NAME
<< HERE
$FROM
$TO
$SUBJECT
$MESSAGE
HERE
exit
0
转载请注明原文地址: https://ju.6miu.com/read-970381.html
专利
最新回复
(
0
)