[Gllug] C and Unix pioneer Dennis Ritchie reported dead

Nix nix at esperi.org.uk
Mon Oct 31 17:38:04 UTC 2011

On 31 Oct 2011, tid stated:

>   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?

Yeah. It's not ideal: shell loops are best avoided, so

sed -i -e 's/fish/chips/g' *.html

would be preferable, both faster and easier to read... they understand
in-place editing but I'm not entirely sure they understand how glob
expansion works.

NULL && (void)
Gllug mailing list  -  Gllug at gllug.org.uk

More information about the GLLUG mailing list