Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2043244
  • 博文数量: 470
  • 博客积分: 10206
  • 博客等级: 上将
  • 技术积分: 5620
  • 用 户 组: 普通用户
  • 注册时间: 2008-07-03 12:50
文章分类

全部博文(470)

文章存档

2012年(1)

2011年(18)

2010年(47)

2009年(404)

分类:

2009-04-10 09:01:04

例如有如下文本:
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

 
 
阅读(614) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~