May 2018
Beginner
332 pages
7h 28m
English
To use sed effectively, we should be clear about how to define range. Range is typically two addresses in a file as follows:
'6d': range of line 6 '3,6d': range from line 3 to 6
'/pattern1/,/pattern2/
As mentioned, we can specify the range as numbers, pattern, or a combination of both, as shown here.
$ cat country.txt
Country Capital ISD Code
USA Washington 1
China Beijing 86
Japan Tokyo 81
India Delhi 91
$ sed -n '/USA/,/Japan/p' country.txt ...