1、写一个sed命令,修改/tmp/input.txt文件的内容
要求:
- 删除所有空行;
- 在非空行前面加一个"AAA",在行尾加一个"BBB",即将内容为11111的一行改为:AAA11111BBB
创造测试文件:
[root@openEuler-22 scripts]# vim /tmp/input.txt
11111
22222
33333
答案:
[root@openEuler-22 scripts]# sed '/^$/d' /tmp/input.txt | sed -r 's/(.*)/AAA\1BBB/'
或(多点分开做):
[root@openEuler-22 scripts]# sed -r -e '/^$/d' -e 's/(.*)/AAA\1BBB/' /tmp/input.txt
效果截图:
2、写出SHELL函数RevertInput
要求: