linux - 如何从模板转换字符串?

标签 linux bash shell

有几行:

echo "1111111111111; 2222222222; 8; 2; 34,12,2,3,5,1; UNKNOW;"

echo "1111111111111; 2222222222; 8; 2; 34,12,2,3,5,1,5,12,45,34; UNKNOW;"

echo "1111111111111; 2222222222; 8; 2; 3; UNKNOW;"

如何取最后一个字符“;”的值和最后一个逗号“,”?

最佳答案

在评论中,您展示了一个满足您检索第 5 个字段的解决方案。这也是可能的

echo "${line}" | cut -d ";" -f5

关于linux - 如何从模板转换字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38674691/

相关文章:

bash - 在awk中使用多个字符串作为分隔符

bash - Vi 是 vim 的别名,但退出时代码为 1

linux - 如何在完成一个 shell 命令后执行其他命令

linux - shell 脚本 : Read the first line of properties file separately form the rest of the lines

linux - srlua makefile 错误 lua.h No such file or directory

linux - vim ./test.py 和 test.py 之间的区别

linux - 我想在 bash 中映射变量的索引

包含文件的更改未在 C 中注册

通过串行接口(interface)用c++连接到cisco路由器

linux - 如何从主脚本中的下标获取退出代码 - bash