使用 sed,如何在第一行上方附加“START”并在最后一行下方附加“END”?
输入文件:
Steve Blenheim:238-923-7366:95 Latham Lane, Easton, PA 83755:11/12/56:20300
Betty Boop:245-836-8357:635 Cutesy Lane, Hollywood, CA 91464:6/23/23:14500
Igor Chevsky:385-375-8395:3567 Populus Place, Caldwell, NJ 23875:6/18/68:23400
Norma Corder:397-857-2735:74 Pine Street, Dearborn, MI 23874:3/28/45:245700
Jennifer Cowan:548-834-2348:583 Laurel Ave., Kingsville, TX 83745:10/1/35:58900
Jon DeLoach:408-253-3122:123 Park St., San Jose, CA 04086:7/25/53:85100
Run Code Online (Sandbox Code Playgroud)
使用“addresses”:1
代表第一行,^
表示该行的开头。$
代表地址中的最后一行,也代表正则表达式中的行尾。
sed -e '1s/^/START\n/' -e '$s/$/\nEND/'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1550 次 |
最近记录: |