新手,刚开始学习shell,今天看了zhy版主的sed,很多地方不明白,希望大家帮忙解释一下,万分感谢!
zhy中的一段程序:
(1)
zhyfly@zhyfly:~/bash$ sed -e '=' test.txt
1
The honeysuckle band played all night long for only $90.
2
It was an evening of splendid music and company.
3
Too bad the disco floor fell through at 23:00.
(2)
zhyfly@zhyfly:~/bash$ sed -e '=' test.txt
1
The honeysuckle band played all night long for only $90.
2
It was an evening of splendid music and company.
3
Too bad the disco floor fell through at 23:00.
4
The local nurse Miss P.Neave was in attendance.
(3)
zhyfly@zhyfly:~/bash$ sed -n -e '=' test.txt
1
2
3
4
(4)
zhyfly@zhyfly:~/bash$ sed -n -e '/music/p' test.txt
It was an evening of splendid music and company.
(5)
zhyfly@zhyfly:~/bash$ sed -n -e '/music/=' test.txt
2
zhyfly@zhyfly:~/bash$ sed -n -e '/music/p' -e '/music/=' test.txt
It was an evening of splendid music and company.
2
(6)
zhyfly@zhyfly:~/bash$ sed -e '=;p' test.txt
1
The honeysuckle band played all night long for only $90.
The honeysuckle band played all night long for only $90.
2
It was an evening of splendid music and company.
It was an evening of splendid music and company.
3
Too bad the disco floor fell through at 23:00.
Too bad the disco floor fell through at 23:00.
4
The local nurse Miss P.Neave was in attendance.
The local nurse Miss P.Neave was in attendance.
(7)
zhyfly@zhyfly:~/bash$ sed -n -e '=;p' test.txt
1
The honeysuckle band played all night long for only $90.
2
It was an evening of splendid music and company.
3
Too bad the disco floor fell through at 23:00.
4
The local nurse Miss P.Neave was in attendance.
(8)
zhyfly@zhyfly:~/bash$ sed -n -e '=' -e 'p' test.txt
1
The honeysuckle band played all night long for only $90.
2
It was an evening of splendid music and company.
3
Too bad the disco floor fell through at 23:00.
4
The local nurse Miss P.Neave was in attendance.
zhyfly@zhyfly:~/bash$
前面四个还明白,到了第五个就不明白了,大家给解释下,谢~ |