如果没有-i参数,碰到下面的情况如何解决?(要用sed,我知道可能awk更容易)
昨天一兄弟的贴的变种:mrgreen:
http://bbs2.chinaunix.net/thread-1365084-1-1.html
[quote]
txt文本:
value1 value2
……
AAAA aaaa
BBBB bbbb
CCCC cccc
……
xml文件:
……
ls -l 查看/etc/rc.local /etc/rc.local -> rc.d/rc.local sed -i /etc/rc.local 这个符号连接后就变样了./etc/rc.local 这个文件就变成一个文件而不是一个符号连接.这样/etc/rc.local 和 /etc/rc.d/rc.local 变成是两个文件了.并且/etc/rc.d/rc.local没有改变. 除了直接修改这个/etc/rc.d/rc.local文件 还有没有其他办法让/etc/rc.local保留原来的符号连接.而不是变成一个新的文件. 请教各位大侠.有没有碰过这个情况?
cat test.sh ftp cdtomb user redflag coling cd file/20031117 get expdat.dmp heh.dmp bye "| ftp -n [m85_4工作主机:]/lq/testdir>sed -n '1d;2,6{a\ > hehehehehe > p > }' test.sh user redflag coling hehehehehe cd file/20031117 hehehehehe get expdat.dmp heh.dmp hehehehehe bye hehehehehe " | ftp -n hehehehehe [m85_4工作主机:]/lq/testdir>sed -n '1d;2,6{p;a\ > hehehehehe > }' test.sh user redflag coling he...
[root@www themes]# ls -l ./newsportal/*.html | sed -i '/\$poll_href/d' sed:无法读取 -:没有那个文件或目录 [root@www themes]# [root@www themes]# sed -i '/\$poll/d' newsportal/vphoto.html; [root@www themes]# 想达到这个目的 [root@www themes]# ls -l ./newsportal/*.html | sed -i '/\$poll_href/d' 该怎么做呢? find能够完成,用这个就行了 find ./newsportal/ -name "*.html"| xargs sed '/$poll_h...
# cat test 1 111 2 123 3 111 4 111 5 555 6 123 7 111 8 456 9 456 10 111 11 456 # sed '/111/:i;N;/123/bi' test 我的意图是,匹配111,然后定义一个标签头,直到遇见123(标签尾),跳出这整个标签,输出结果。 可命令报错。不解。 情高手帮忙看下。谢谢。
1. awk后不用输出额外文件, 只修改输入文件. 类似sed -i 2. 匹配的不输出, 不匹配的输出. 类似grep -v 3. print { $2,$1,$3,$4,$5,$6,$7,$8} 可否有类似 print {$2,$1,$else} 或者 print {$2,$1,$0-2}简便写法