Here's what I've tried with sed and here's what I'm getting.
From this list in a file called "baseball"
if I try
sed -n -e '1p;' -e '3p;' baseball
but if I should add another line number, as I did here
sed -n '2p; 4p; 1p' baseball
which are the right lines, just not in the order I asked for them. When I add another line number reference (e.g: 5p
), it returns the first four lines in the file, but not
line 5, which is what I asked for.
I'm thinking that because sed processes things in a stream (hence the name), and can find and return single lines, line pairs and ranges, it can't do anything as fancy as return many lines by their line number in any order that "goes against the stream."
So what does
Or better, what would be a better way of reading in lines like the ones in baseball
, and returning them in a "custom" order?