在bash中对变量进行多个正则表达式替换?
发布时间:2020-12-15 22:44:42 所属栏目:安全 来源:网络整理
导读:我想知道是否有办法在bash中进行多个正则表达式替换 ${string // substring / replacement}或者可能存在更好的解决方案. 我有一个脚本,用curl向statusnet和friendika发送更新. 例如,我在网上签署请愿书,并且我可以发送推文,但宁愿发送到identica.我厌倦了粘
我想知道是否有办法在bash中进行多个正则表达式替换
${string // substring / replacement}或者可能存在更好的解决方案. 我有一个脚本,用curl向statusnet和friendika发送更新. @repbunghole and @SenatorArsehat Stop farking around with #someship! Do you want me to come smack you? | http://someshort.url 至 @repbunghole @SenatorArsehat Stop farking around with #someship!! Do you want me to come smack you? | http://someshort.url 我没有强大的sed或awk fu,但想象他们可能提供解决方案,我不知道如何使用sed而不将变量写入文件,读取文件并对其进行操作,然后使用var =设置var $(猫文件).是.我对这个东西很陌生. 喜欢 read -p "Enter a string: " a b=${a//@/@} c=${b//#/#} d=${c//!/!} e=${d//?/?} f=${e//"/"} g=${f//'/'} 等等 解决方法
这就是
character classes的用途:
b=${a//[@#!?"']/ } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |