我有这样的文件:
1. blah zend blahblahblahblah
2. blahblahblah blahblahblah Zend
3. Zend blahblahblahblahblahblah blah
4. Yii blahblahblahblahblahblah
5. blahblahblahblahblahblah Yii
6. CI blahblahblahblahblahblahblahblah
7. blahblahblahblahblahblahblahblah CI
我想要的是:使用shell读取该文件的每一行,当该行包含Zend时,它将在行尾附加一个“a”,当行包含Yii时附加一个'b'并附加一个' c' 当该行包含 CI 时。
我真的不知道如何在一个 shell 命令中执行此操作,有人可以切碎吗?
不过,我设法一一做到了,例如:
cat test2 | while read line; do echo "$line a" | grep Zend || echo $line; done > test
我想我需要的是“while”和“if”的组合