[lfs-support] A bug in gawk?

alex lupu alupu01 at gmail.com
Fri Oct 11 15:56:23 PDT 2013


gawk - v. <= 4.1.0
sed - v. whatever

I have a file, 'tempx.txt' containing
 (for simplicity - some "so" files from my '/usr/lib/'),

[]$ cat tempx.txt
libexpect5.43.so
libsndfile.so.1.0.25
libsoftokn3.so
libsoup-2.4.so.1.5.0

and I would like to separate their "roots" from the rest, i.e.,

"libsndfile.so.1.0.25" --> "libsndfile", etc.

so I (instinctively) try:

[]$ cat tempx.txt | awk 'BEGIN {FS=".so"} ; {print $1}'
libexpect5.43
libsndfile
li
li

then this (to show off I know a thing or two about escapes):

[/usr/lib]$ cat tempx.txt | awk 'BEGIN {FS="\.so"} ; {print $1}'
 awk: cmd. line:1: warning: escape sequence `\.' treated as plain `.'
libexpect5.43
libsndfile
li
li

Terrible.

Surprisingly, this ugly hack (bringing 'sed' into the picture)
accomplishes what I intended.

First, to test the waters,
[]$ sed -e 's/\.so/YYY/' tempx.txt
libexpect5.43YYY
libsndfileYYY.1.0.25
libsoftokn3YYY
libsoup-2.4YYY.1.5.0

then, finally,

[]$ sed -e 's/\.so/YYY/' tempx.txt | awk 'BEGIN {FS="YYY"} ; {print $1}'
libexpect5.43
libsndfile
libsoftokn3
libsoup-2.4

Is there a problem with GNU gawk and/or my system or maybe with me?

Thanks,
-- Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfromscratch.org/pipermail/lfs-support/attachments/20131011/193fb66c/attachment.html>


More information about the lfs-support mailing list