[Gllug] one-liner
JLMS
jjllmmss at googlemail.com
Tue Nov 15 02:12:22 UTC 2011
On 31 October 2011 17:24, Dimitrios Siganos <dimitris at siganos.org> wrote:
> IMO, a one-liner is not a well defined concept, hence, you can't say that
> his solution is not a one liner unless you have provided a precise
> definition for what a one liner is. It fits in one line, hence, it looks
> like a one-liner to to me. If your colleague wanted a single command
> solution then he should have been more specific.
Of course you can say that, some people would bow to your attention to
detail, I tend to be moody and would think, most likely unfairly, that
you are being pedantic for the fun of it.
You can use common sense interpreting the one liner requirement (which
I think most people with some basic understanding of scripting would
interpret in a reasonable manner) and that way live happily with the
rest of humanity.
>
> What's more interesting is that his solution won't work correctly for
> file-names which contain spaces.
It would have been even more interesting to mention a possible
solution taking care of the problem you correctly highlight:
In bash:
for i in "*.html" ; do sed -i -e 's/fish/chips/g' $i ; done
>
> Dimitris
>
> On 31/10/11 16:57, tid wrote:
>
> A colleague asked my opinion as to whether I felt the following was a
> correct answer to an test question:
>
> Q: Please supply a one-line command to substitute all occurences of 'fish'
> to 'chips' in all files ending in .html
>
> -A: $ for i in *.html ; do sed -i -e 's/fish/chips/g' $i ; done
>
> I'm not sure about this : it's written on one line but it's not really a
> one-liner or is it? The point of the test is
> measure the student's skill and they've shown that they understand in-place
> editing so I'm inclined
> to give them the point. What do others think?
>
> Tid
>
>
>
> --
> Gllug mailing list - Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
>
> --
> Gllug mailing list - Gllug at gllug.org.uk
> http://lists.gllug.org.uk/mailman/listinfo/gllug
>
>
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list