Sed - An Introduction and Tutorial by Bruce Barnett
|
Do not fret!?It is not your fault you don't understand?sed. I will cover?sed?completely. But I will describe the features in the order that I learned them. I didn't learn everything at once. You don't need to either. Sed?has several commands,but most people only learn the substitute command:?s. The substitute command changes all occurrences of the regular expression into a new value. A simple example is changing "day" in the "old" file to "night" in the "new" file: sed s/day/night/ Or another way (for UNIX beginners), sed s/day/night/ old >new and for those who want to test this: echo day | sed s/day/night/ This will output "night". I didn't put quotes around the argument because this example didn't need them. If you read my earlier tutorial?,you would understand why it doesn't need quotes. However,I recommend you do use quotes. If you have meta-characters in the command,quotes are necessary. And if you aren't sure,it's a good habit,and I will henceforth quote future examples to emphasize the "best practice." Using the strong (single quote) character,that would be: sed 's/day/night/' I must emphasize that the sed editor changes exactly what you tell it to. So if you executed echo Sunday | sed 's/day/night/' This would output the word "Sunnight" because sed found the string "day" in the input. Another important concept is that sed is line oriented. Suppose you have the input file: one two three,one two three four three two one one hundred and you used the command sed 's/one/ONE/' |
- Linux etcrc.drc.local配置文件用法介绍
- linux – 我的进程如何检测计算机是否正在关闭?
- c – GDB在启动时崩溃(内部错误:follow_die_offset)
- 过年送这个倍儿有面儿!四季沐歌太阳能热水器3680元
- linux-kernel – 绑定驱动程序如何从奴役接口获取RX数据包
- Linux tail命令显示文件结尾的内容
- 10 Linux DIG Command Examples for DNS Lookup--reference
- 唱吧怎么上榜 长沙style恶霸堂客上榜分析
- Jvm原理分析,看了都说好
- linux – 使用10GB内存的Haproxy和50k连接的100%CPU

