Fwd: LFS Script suggestion

Ismael Luceno ismael.luceno at gmail.com
Mon Jan 29 20:12:41 PST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Bruce Dubbs escribió:
> Dan Nicholson wrote:
>> On 1/29/07, Bruce Dubbs <bruce.dubbs at gmail.com> wrote:
>>> Dan Nicholson wrote:
>>>> On 1/28/07, Alexander E. Patrakov <patrakov at ums.usu.ru> wrote:
>>>>> Tushar Teredesai wrote:
>>>>>> cat /proc/version | head -n1 | cut -d" " -f1-3,5-7
>>>> Pet peeve. Don't use cat to create input streams when the shell is
>>>> perfectly capable on it's own with <.
>>> vs
>>>
>>>> sed -n 's/.*gcc version \([^() ]*\)[() ].*/\1/p;q' < /proc/version
>>> >From an educational view, what's wrong with showing a different way of
>>> doing things.
>>>
>>> Actually Tush's version above is much clearer to me than your sed,
>>> although I don't think the head -n1 is needed (it may be in some cases,
>>> but not for my systems).
>> OK, but it still needs to be fixed to work on Debian. Here's the
>> output from Alexander's version string:
>>
>> [ 5:28 PM dan at conor] cat foo | head -n1 | cut -d" " -f1-3,5-7
>> Linux version 2.6.18-3-686 2.6.18-7) (waldi at debian.org) (gcc
>>
>> It might be best to cat the whole file like he mentioned unless you
>> want to have a much more heavy duty parser.
> 
> OK, I see now.  Debian adds a field to their string.  In that case a sed
> is definitely needed.
> 
>>From one of mine (Obviously not LFS):
> 
> Linux version 2.6.9-42.0.3.EL_lustre.1.5.97smp (ltest at scsi1) (gcc
> version 3.4.4 20050721 (Red Hat 3.4.4-2)) #1 SMP Fri Jan 12 17:22:43 MST
> 2007
> 
> And Alex:
> 
> Linux version 2.6.18-3-686 (Debian 2.6.18-7) (waldi at debian.org) (gcc
> version 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)) #1 SMP Mon Dec 4
> 16:41:14 UTC 2006
> 
> How about:
> 
> $ sed -r 's/.*(gcc version [01234567890\.]+).*/\1/' /proc/version

This string depends on the locale in use when the kernel was compiled,
so it will not work on all systems, it needs to be more generic:

$ cat /proc/version
Linux version 2.6.19.1 (ismaell at localhost) (gcc versión 4.0.3) #1 Fri
Dec 15 02:19:26 UYT 2006

$ sed -r 's/.*\((gcc .+ [01234567890\.]+)\).*/\1/' /proc/version
gcc versión 4.0.3

- --
Ismael Luceno
<ismael.luceno at gmail.com>
<ismael at initng.org>

InitNG maintainer and project lead - http://www.initng.org

Registered Linux User #439653      - http://counter.li.org
LFS User #17162                    - http://www.linuxfromscratch.org

Jabber ID: ismael.luceno at jabberes.org
IRC: ismaell @ irc.freenode.org #initng

GPG Key ID: EC8E5C9A
GPG Key Fingerprint: 1356 7578 232E CCA6 D16D 46A8 FE6C 58D3 EC8E 5C9A
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.3 (GNU/Linux)

iD8DBQFFvsW5/mxY0+yOXJoRAuUyAKCS0pUO1++r/MxcO8i7o75f4VZcpgCfcDym
9LOP2JIHHrhikEUTh3C0WoM=
=B7Tw
-----END PGP SIGNATURE-----




More information about the lfs-dev mailing list