我正在寻找一种方法来绕过读写文件。 是否有可能直接使用sed命令的结果?使用 #!/bin/sh
,因为我使用NetBSD,sed -i
不能正常工作,所以我必须使用sed -e
,然后将结果重定向到文件。使用sed而不需要写入文件
结果命令disklabel xbd0
netbsd# disklabel xbd0 >/file ;
# /dev/rxbd0d:
type: unknown
disk: xbd0
label:
flags:
bytes/sector: 512
sectors/track: 2048
tracks/cylinder: 1
sectors/cylinder: 2048
cylinders: 1000
total sectors: 2048000
rpm: 3600
interleave: 1
trackskew: 0
cylinderskew: 0
headswitch: 0 # microseconds
track-to-track seek: 0 # microseconds
drivedata: 0
16 partitions:
# size offset fstype [fsize bsize cpg/sgs]
a: 2048000 0 4.2BSD 1024 8192 0 # (Cyl. 0 - 999)
c: 2048000 0 unused 0 0 # (Cyl. 0 - 999)
d: 2048000 0 unused 0 0 # (Cyl. 0 - 999)
netbsd# disklabel xbd0 | sed -e "s/match1/replace/" \
-e "s/match2/replace/" \
-e "s/match3/replace/" /file > /file.1 ;
如何发送另一个命令里面的结果吗?
$ new_command -add $(results)
你们是不是重定向命令 的结果 “磁盘标签xbd0 | sed的-e ”S/MATCH1 /替换/“ \ -e ”S/MATCH2 /替换/“ \ -e” S/MATCH3 /替换/ “/文件”到/file.1? – 2013-03-26 14:59:18