substring-extraction.sh
来自「Shall高级编程」· Shell 代码 · 共 23 行
SH
23 行
#!/bin/bash# substring-extraction.shString=23skidoo1# 012345678 Bash# 123456789 awk# Note different string indexing system:# Bash numbers first character of string as '0'.# Awk numbers first character of string as '1'.echo ${String:2:4} # position 3 (0-1-2), 4 characters long # skid# The awk equivalent of ${string:pos:length} is substr(string,pos,length).echo | awk '{ print substr("'"${String}"'",3,4) # skid}'# Piping an empty "echo" to awk gives it dummy input,#+ and thus makes it unnecessary to supply a filename.exit 0
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?