lkml.org 
[lkml]   [1999]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: sed not working on /proc files
    On Mon, 26 Apr 1999, Stefan Monnier wrote:

    > How do you explain the following problem (with 2.2.6):
    >
    > # (sed 's/a/a/') </proc/modules
    > # (cat | sed 's/a/a/') </proc/modules
    > nfsd 147288 1 (autoclean)
    > nfs 27856 2 (autoclean)
    > lockd 29000 1 (autoclean) [nfsd nfs]
    > sunrpc 48492 1 (autoclean) [nfsd nfs lockd]
    > autofs 8872 1 (autoclean)
    > 3c59x 17456 1 (autoclean)
    > opl3 10264 0
    > cs4232 2264 0
    > ad1848 15152 0 [cs4232]
    > uart401 5628 0 [cs4232]
    > sound 55080 0 [opl3 cs4232 ad1848 uart401]
    > soundcore 2208 6 [sound]
    > binfmt_misc 3108 0
    > st 23352 0
    > softdog 948 1
    > unix 10056 72 (autoclean)
    > #
    >

    -r--r--r-- 1 root root 0 Apr 26 17:28 /proc/meminfo
    ^_______ zero

    It happens because files in /proc have zero length. These are not
    real files. To use `sed` and utilities that do lseek you can `cat`
    through a pipe as you have done. Sed's first 'lseek()' returns ESPIPE
    which tells it to not do that again -- and everything is fine.


    Cheers,
    Dick Johnson
    ***** FILE SYSTEM WAS MODIFIED *****
    Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
    Warning : It's hard to remain at the trailing edge of technology.


    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.rutgers.edu
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2005-03-22 13:51    [W:0.020 / U:0.248 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site