当前位置: 技术问答>linux和unix
如何用sed命令在某个文件中加上一行啊。。。
来源: 互联网 发布时间:2016-11-18
本文导语: 比如说:我的文件是这样的: STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('103libgw') export symbol('AD_UA_SP_RS') export symbol('GW_del_ctx') export symbol('gw_nw_unchain_rcv_action') export symbol('gw_shm_addentry') export symbol('g...
比如说:我的文件是这样的:
STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('103libgw')
export symbol('AD_UA_SP_RS')
export symbol('GW_del_ctx')
export symbol('gw_nw_unchain_rcv_action')
export symbol('gw_shm_addentry')
export symbol('gw_shm_addproc')
export symbol('gw_shm_atchseg')
export symbol('gw_shm_crseg1')
export symbol('gw_shm_crtbl')
export symbol('gw_shm_delproc')
export symbol('gw_shm_del_blob')
export symbol('gw_shm_del_entry')
export symbol('gw_shm_find_seg')
export symbol('gw_shm_getbykey')
export symbol('gw_shm_getbylink')
export symbol('gw_shm_getbynum')
export symbol('gw_shm_getnum')
export symbol('gw_shm_getnxtrsvc_bykey')
export symbol('gw_shm_getprin_byappkey')
export symbol('gw_shm_make_gtrid')
export symbol('gw_shm_make_gtrid_autotran')
export symbol('gw_shm_rdom_links')
export symbol('gw_shm_rsvc_links')
export symbol('gw_shm_settran_bytxid')
export symbol('gw_shm_splitrout')
export symbol('gw_shm_tbl_start')
export symbol('gw_shm_test_gwadm')
export symbol('load_snadom_entries')
export symbol('load_tdom_entries')
export symbol('parsedata')
export symbol('read_acl_entries')
export symbol('read_ldom_info')
export symbol('read_lsvc_entries')
export symbol('read_ositp_entries')
export symbol('rqst_imq')
export symbol('nw_imq')
export symbol('rply_imq')
ENDPGMEXP
这种文件的export的数量是不固定的。。。
同时,这是在makefile文件中写上这么一段sed命令,使得能在最后一个export后面再加上一行,比如说“export symbol('another_function')”.
这个应该怎么搞?
STRPGMEXP PGMLVL(*CURRENT) SIGNATURE('103libgw')
export symbol('AD_UA_SP_RS')
export symbol('GW_del_ctx')
export symbol('gw_nw_unchain_rcv_action')
export symbol('gw_shm_addentry')
export symbol('gw_shm_addproc')
export symbol('gw_shm_atchseg')
export symbol('gw_shm_crseg1')
export symbol('gw_shm_crtbl')
export symbol('gw_shm_delproc')
export symbol('gw_shm_del_blob')
export symbol('gw_shm_del_entry')
export symbol('gw_shm_find_seg')
export symbol('gw_shm_getbykey')
export symbol('gw_shm_getbylink')
export symbol('gw_shm_getbynum')
export symbol('gw_shm_getnum')
export symbol('gw_shm_getnxtrsvc_bykey')
export symbol('gw_shm_getprin_byappkey')
export symbol('gw_shm_make_gtrid')
export symbol('gw_shm_make_gtrid_autotran')
export symbol('gw_shm_rdom_links')
export symbol('gw_shm_rsvc_links')
export symbol('gw_shm_settran_bytxid')
export symbol('gw_shm_splitrout')
export symbol('gw_shm_tbl_start')
export symbol('gw_shm_test_gwadm')
export symbol('load_snadom_entries')
export symbol('load_tdom_entries')
export symbol('parsedata')
export symbol('read_acl_entries')
export symbol('read_ldom_info')
export symbol('read_lsvc_entries')
export symbol('read_ositp_entries')
export symbol('rqst_imq')
export symbol('nw_imq')
export symbol('rply_imq')
ENDPGMEXP
这种文件的export的数量是不固定的。。。
同时,这是在makefile文件中写上这么一段sed命令,使得能在最后一个export后面再加上一行,比如说“export symbol('another_function')”.
这个应该怎么搞?
|
sed '/ENDPGMEXP/ i
export symbol('another_function')
{新的文件}
直接打四个空格进去试试
export symbol('another_function')
{新的文件}
直接打四个空格进去试试