文件:
cat file | tr -d "a-zA-Z">new_file
变量:
new_str=$(echo $str | tr -d "a-zA-Z")
本文介绍了一种使用Linux命令行工具处理字符串的方法,通过cat和tr命令组合实现去除字符串中的所有字母字符。此技巧适用于需要对文本数据进行预处理或清理的场景。
文件:
cat file | tr -d "a-zA-Z">new_file
变量:
new_str=$(echo $str | tr -d "a-zA-Z")
1057

被折叠的 条评论
为什么被折叠?