开发者

bash / sed rewriting of variables for sip links

im trying to use a bash script to replace all none numeric characters from a phone number,

here is a working exemple in php:

#!/usr/bin/php
<?php
        $nr = preg_replace('#[^0-9]#', '', implode(" ", array_slice($argv, 1)));
        exec("qutecom -c call/0{$nr}");
?>

but i don't want to install php on all computers, bash with sed should be able to solve this, im just not 开发者_开发技巧good at writing sed commands, tried this whitout any luck

echo " sdf sdf sdf0736-41 43 51 sdfasfd " | sed -e "s/[^0-9]+//g"

that i hoped should return "0736414351"


my current solution

qutecom -c call/0`echo "$*" | sed 's/[^0-9]//g'`


simply do:

echo " sdf sdf sdf0736-41 43 51 sdfasfd " | sed 's/[^0-9]//g'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜