[Gllug] Awk and filenames with spaces in them
Martyn Drake
martyn at drake.org.uk
Tue Sep 25 15:58:56 UTC 2007
On 25/09/2007, Wulf Forrester-Barker <basswulf at googlemail.com> wrote:
> Thinking around the problem, is it possible to either prevent names
> with spaces being used or to force the log file to use a different
> delimiter? Either of those would then make parsing the logs simpler.
Nope. We're talking about people working in the entertainment
industry here - not a chance in hell of stopping that from happening
and thus I must build as much error checking and user friendliness as
it is possible. :)
> Alternatively, you could either check the number of fields in a given
> line and ignore / report on those that don't give the number you
> expect. Stepping beyond that, there may be other ways you can describe
> the field you want to extract and measure, such as "the third before
> the end" ($NF - 3? I'd have to check to be sure) instead as the more
> obvious "X from the beginning" ($X).
Indeed, I hadn't realised about the variables that awk can use and as
such I got around the issue with counting the number of bytes by
counting back using $NF. As for getting the actual filename which is
completely encased in double quote marks, awk -F\" '{ print $2 }' did
the trick nicely and I can then manipulate the filename accordingly.
Thanks all.
Regards,
Martyn
--
Email : martyn at drake.org.uk
Phone : +44 (0)7866 450 752
Skype : mbdrake
Blog : http://www.drake.org.uk
--
Gllug mailing list - Gllug at gllug.org.uk
http://lists.gllug.org.uk/mailman/listinfo/gllug
More information about the GLLUG
mailing list