例如有如下文本:
1 set -x
2 echo
3 echo "Testing \"0\""
4 if [ 0 ] # zero
5 then
6 echo "0 is true."
....
120 echo"good"
怎么样才能删除每行行首的数字,好像用sed实现能实现,可我不会啊!
[root@Greendays lianshou]# sed 's/[0-9]* //' c
set -x
echo
echo "Testing \"0\""
if [ 0 ] # zero
then
echo "0 is true."
echo"good"
[root@Greendays lianshou]# sed 's/^[0-9]+//' c
1 set -x
2 echo
3 echo "Testing \"0\""
4 if [ 0 ] # zero
5 then
6 echo "0 is true."
120 echo"good"
[root@Greendays lianshou]# sed -r 's/^[0-9]+//' c
set -x
echo
echo "Testing \"0\""
if [ 0 ] # zero
then
echo "0 is true."
echo"good"
[root@Greendays lianshou]# awk '{$1=""; print}' c
set -x
echo
echo "Testing \"0\""
if [ 0 ] # zero
then
echo "0 is true."
echo"good"
这里有个类似的问题
1 abc
20 bcd
d sadf
df sdf
删除每行第一项变为
abc
bcd
sadf
sdf
这个又如何实现?
[root@Greendays lianshou]# cat d
1 abc
20 bcd
d sadf
df sdf
[root@Greendays lianshou]# awk '{$1=""; print}' d
abc
bcd
sadf
sdf
阅读(656) | 评论(0) | 转发(0) |