| Newsgroups |
gmane.editors.sed.user |
| Message-ID |
<[email protected]> |
I'm sorry, but I need to point out that it is incorrect to say that the given script can be "made into a 1-liner by putting each uncommented line above in an -e '....' block, to get as many -e '...' blocks as the number of lines."
I have never seen a definition of "one-liner". So it's understandable some might be confused. However, this seems pretty basic to me. I submit that a long script cannot be a "one-liner", unless converted to a short script. I believe there is consensus that "one-liner" means "short script written on one line". Here is my reasoning:
1) Usage - Each http://sed.sourceforge.net/sed1line.txt http://sed.sourceforge.net/sed1line.txt example is a "short script written on one line". The usage on this famous page makes the definition clear. 2) Common sense - If any script can be a one-liner by putting each line into a -e block, then one-liner has no meaning, because any script would qualify. However, common sense says "one-liner" does have a meaning ("short script written on one line").
There is nothing wrong with long sed scripts, as long as they work, are easy to understand, and easy to maintain. The given script is not easy to understand and maintain. However, converting it to a "one-liner" makes it even worse. It ends up about 180 columns long, all strung out on one line. This qualifies as a "coding horror", is a bad idea no matter what we call it:
sed -e '/^>/!b' -e '$q' -e '/.\{30\}./!b' -e 'N' -e '/^\(\(> \)\2*\)[^>].*\n\1[^>]/!{P;D;}' -e '/\n\(> \)\1*$/b' -e '/\n>.\{30\}./{P;D;}' -e '/^>.\{50\}.*\n/s/\n\(> \)\1*//' comb_quoted_file :(
Words are important. To have meaningful discussion, we have to agree on basic concepts and vocabulary. If "one-liner" does not mean "short script written on one line", I'd like to hear. Or if someone agrees with my suggested definition, that would also be helpful.
Thanks.
Daniel
------------------------------
sed -e '
# v3.0
# skip uncited, last, & small lines
/^>/!b
$q
/.\{30\}./!b
N
/^\(\(> \)\2*\)[^>].*\n\1[^>]/!{P;D;}
/\n\(> \)\1*$/b
/\n>.\{30\}./{P;D;}
/^>.\{50\}.*\n/s/\n\(> \)\1*//
' comb_quoted_file
can be made into a 1-liner by putting each uncommented line above in an -e '....' block, to get as many -e '...' blocks as the number of lines.
[Non-text portions of this message have been removed]