[转载] sed question# Unix - 噫吁兮,危乎高哉
i*d
1 楼
【 以下文字转载自 Linux 讨论区 】
【 原文由 Iamold 所发表 】
file1.txt contains
asdfasdf
adsf
asdfasdfsdf
#ifdef CONFIG_SCSI_MULTI_LUN
static int max_scsi_luns = 32;
#else
static int max_scsi_luns = 1;
#endif
I want to replace lines from CONFIG_SCSI_MULTI_LUN to #endif
how to do this by using sed?
the following command yielded a wrong output...
sed '/CONFIG_SCSI_MULTI_LUN/,/endif/{c\
#ifdef CONFIG_SCSI_MULTI_LUN\
static int max_scsi_luns = 32;\
#else\
static int max_scsi_luns = 1;\
#endif
;}' file1.txt > output.txt
【 原文由 Iamold 所发表 】
file1.txt contains
asdfasdf
adsf
asdfasdfsdf
#ifdef CONFIG_SCSI_MULTI_LUN
static int max_scsi_luns = 32;
#else
static int max_scsi_luns = 1;
#endif
I want to replace lines from CONFIG_SCSI_MULTI_LUN to #endif
how to do this by using sed?
the following command yielded a wrong output...
sed '/CONFIG_SCSI_MULTI_LUN/,/endif/{c\
#ifdef CONFIG_SCSI_MULTI_LUN\
static int max_scsi_luns = 32;\
#else\
static int max_scsi_luns = 1;\
#endif
;}' file1.txt > output.txt