Post B6o1X78hp1ua7p7qGu by me@social.jlamothe.net
(DIR) More posts by me@social.jlamothe.net
(DIR) Post #B6nvY3j5OlFY6VD2wa by ed1conf@bsd.network
1 likes, 0 repeats
A recent discussion about ranges in ed(1) & vi(1) led to detailing the difference between using a comma and using a semicolon when separating the beginning/end of a range.To clearly demonstrate the difference, create a file with 20 sequential numbers in it:$ jot 20 > data.txt # or use seq 20and open it to line 10:$ ed data.txt 51 10If you use a semicolon like?5?;/8/nit will search backwards from the current line (line 10) for the line containing "5" (line 5) and then from line 5 search forward to the next line containing "8" (line "8") line and print/number those 4 lines.If instead you're on line 10 and you use a comma like?5?,/8/nit will search backwards for the line containing "5" (line 5), then search forwards for "8" from your starting location (line 10), landing on "18", and print/number those 14 lines.
(DIR) Post #B6nxzqxgeLmSX3Q5mC by ed1conf@bsd.network
0 likes, 0 repeats
@kevinbowen For a while, BSD systems provided jot(1) where Linux systems provided seq(1). It looks like both my FreeBSD & OpenBSD systems now come with both in a base install.
(DIR) Post #B6o1X78hp1ua7p7qGu by me@social.jlamothe.net
0 likes, 0 repeats
@ed1conf Thank you. I have to admit, I've always been a little fuzzy on the difference between , and ;.
(DIR) Post #B6o1X7aMAE1tVa3vN2 by me@social.jlamothe.net
0 likes, 0 repeats
@ed1conf If I'm not mistaken, the other difference is that if you omit the actual references, , will default to 1,$ whereas ; will default to n,$.At least, I think... I always have to look it up.
(DIR) Post #B6o1X7jvadgZzGXZI0 by ed1conf@bsd.network
0 likes, 0 repeats
@me For ed(1), you are correct:,nwill number the entire file while;nwill number the current line through the end of the file.Meanwhile vi(1) doesn't like either (:,# and :;# both just number the current line)
(DIR) Post #B6oZlIiswrPkXwz6Lw by lanodan@queer.hacktivis.me
0 likes, 0 repeats
@sirjofri @ed1conf @kevinbowen As far as I can tell the Plan9 and Unix-derived seq(1) are equivalent for most usage, the {Net,Free}BSDs manpages even mentions Plan9 but also that it first appeared in Version 8 AT&T Unix.