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'
精彩评论