problem with "find" command - Linux

This is a discussion on problem with "find" command - Linux ; I am running Fedora Core 3. This find command worked... [root@host /]# find /etc -exec grep "hsd1" {} \; -print search hsd1.tx.comcast.net. /etc/resolv.conf search hsd1.tx.comcast.net. /etc/sysconfig/networking/profiles/default/resolv.conf search hsd1.tx.comcast.net /etc/resolv.conf.master [root@host /]# This printed 24 lines in the first few seconds ...

+ Reply to Thread
Results 1 to 11 of 11

Thread: problem with "find" command

  1. problem with "find" command

    I am running Fedora Core 3.
    This find command worked...

    [root@host /]# find /etc -exec grep "hsd1" {} \; -print
    search hsd1.tx.comcast.net.
    /etc/resolv.conf
    search hsd1.tx.comcast.net.
    /etc/sysconfig/networking/profiles/default/resolv.conf
    search hsd1.tx.comcast.net
    /etc/resolv.conf.master
    [root@host /]#

    This printed 24 lines in the first few seconds and nothing more.

    [root@host /]# find / -exec grep "host.domain.com" {} \; -print | less
    grep: /selinux/booleans/allow_ypbind: Invalid argument
    grep: /selinux/booleans/ypbind_disable_trans: Invalid argument
    grep: /selinux/booleans/winbind_disable_trans: Invalid argument
    grep: /selinux/booleans/syslogd_disable_trans: Invalid argument
    grep: /selinux/booleans/squid_disable_trans: Invalid argument
    grep: /selinux/booleans/snmpd_disable_trans: Invalid argument
    grep: /selinux/booleans/postgresql_disable_trans: Invalid argument
    grep: /selinux/booleans/portmap_disable_trans: Invalid argument
    grep: /selinux/booleans/ntpd_disable_trans: Invalid argument
    grep: /selinux/booleans/nscd_disable_trans: Invalid argument
    grep: /selinux/booleans/named_write_master_zones: Invalid argument
    grep: /selinux/booleans/named_disable_trans: Invalid argument
    grep: /selinux/booleans/mysqld_disable_trans: Invalid argument
    grep: /selinux/booleans/dhcpd_disable_trans: Invalid argument
    grep: /selinux/booleans/httpd_disable_trans: Invalid argument
    grep: /selinux/booleans/httpd_tty_comm: Invalid argument
    grep: /selinux/booleans/httpd_ssi_exec: Invalid argument
    grep: /selinux/booleans/httpd_enable_homedirs: Invalid argument
    grep: /selinux/booleans/httpd_enable_cgi: Invalid argument
    grep: /selinux/booleans/httpd_unified: Invalid argument
    grep: /selinux/disable: Invalid argument
    grep: /selinux/commit_pending_bools: Invalid argument
    grep: /selinux/context: Invalid argument
    grep: /selinux/load: Invalid argument

    I waited at least 30 minutes, and nothing more was printed.
    I hit control-C and got a colon prompt and I entered q to quit less.
    Tnx,
    Charles



  2. Re: problem with "find" command

    Charles wrote:
    > I am running Fedora Core 3.
    > This find command worked...
    >
    > [root@host /]# find /etc -exec grep "hsd1" {} \; -print
    > search hsd1.tx.comcast.net.
    > /etc/resolv.conf
    > search hsd1.tx.comcast.net.
    > /etc/sysconfig/networking/profiles/default/resolv.conf
    > search hsd1.tx.comcast.net
    > /etc/resolv.conf.master
    > [root@host /]#
    >
    > This printed 24 lines in the first few seconds and nothing more.
    >
    > [root@host /]# find / -exec grep "host.domain.com" {} \; -print | less
    > grep: /selinux/booleans/allow_ypbind: Invalid argument
    > grep: /selinux/booleans/ypbind_disable_trans: Invalid argument
    > grep: /selinux/booleans/winbind_disable_trans: Invalid argument
    > grep: /selinux/booleans/syslogd_disable_trans: Invalid argument
    > grep: /selinux/booleans/squid_disable_trans: Invalid argument
    > grep: /selinux/booleans/snmpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/postgresql_disable_trans: Invalid argument
    > grep: /selinux/booleans/portmap_disable_trans: Invalid argument
    > grep: /selinux/booleans/ntpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/nscd_disable_trans: Invalid argument
    > grep: /selinux/booleans/named_write_master_zones: Invalid argument
    > grep: /selinux/booleans/named_disable_trans: Invalid argument
    > grep: /selinux/booleans/mysqld_disable_trans: Invalid argument
    > grep: /selinux/booleans/dhcpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/httpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/httpd_tty_comm: Invalid argument
    > grep: /selinux/booleans/httpd_ssi_exec: Invalid argument
    > grep: /selinux/booleans/httpd_enable_homedirs: Invalid argument
    > grep: /selinux/booleans/httpd_enable_cgi: Invalid argument
    > grep: /selinux/booleans/httpd_unified: Invalid argument
    > grep: /selinux/disable: Invalid argument
    > grep: /selinux/commit_pending_bools: Invalid argument
    > grep: /selinux/context: Invalid argument
    > grep: /selinux/load: Invalid argument
    >
    > I waited at least 30 minutes, and nothing more was printed.
    > I hit control-C and got a colon prompt and I entered q to quit less.
    > Tnx,
    > Charles
    >
    >


    Be careful running 'find' from the root dir. make sure you're
    logged in as 'root' to do that. 'grep' may hang if any of the
    files passed to it are 'psuedo files' (files that have no end, they
    just keep producing data as long as you/grep keep reading from the
    file, e.g. /dev/zero, etc).

    Regards,
    Larry

    --
    Anti-spam address, change each 'X' to '.' to reply directly.

  3. Re: problem with "find" command

    Larry I Smith wrote:
    > Charles wrote:
    >> I am running Fedora Core 3.
    >> This find command worked...
    >>
    >> [root@host /]# find /etc -exec grep "hsd1" {} \; -print
    >> search hsd1.tx.comcast.net.
    >> /etc/resolv.conf
    >> search hsd1.tx.comcast.net.
    >> /etc/sysconfig/networking/profiles/default/resolv.conf
    >> search hsd1.tx.comcast.net
    >> /etc/resolv.conf.master
    >> [root@host /]#
    >>
    >> This printed 24 lines in the first few seconds and nothing more.
    >>
    >> [root@host /]# find / -exec grep "host.domain.com" {} \; -print | less
    >> grep: /selinux/booleans/allow_ypbind: Invalid argument
    >> grep: /selinux/booleans/ypbind_disable_trans: Invalid argument
    >> grep: /selinux/booleans/winbind_disable_trans: Invalid argument
    >> grep: /selinux/booleans/syslogd_disable_trans: Invalid argument
    >> grep: /selinux/booleans/squid_disable_trans: Invalid argument
    >> grep: /selinux/booleans/snmpd_disable_trans: Invalid argument
    >> grep: /selinux/booleans/postgresql_disable_trans: Invalid argument
    >> grep: /selinux/booleans/portmap_disable_trans: Invalid argument
    >> grep: /selinux/booleans/ntpd_disable_trans: Invalid argument
    >> grep: /selinux/booleans/nscd_disable_trans: Invalid argument
    >> grep: /selinux/booleans/named_write_master_zones: Invalid argument
    >> grep: /selinux/booleans/named_disable_trans: Invalid argument
    >> grep: /selinux/booleans/mysqld_disable_trans: Invalid argument
    >> grep: /selinux/booleans/dhcpd_disable_trans: Invalid argument
    >> grep: /selinux/booleans/httpd_disable_trans: Invalid argument
    >> grep: /selinux/booleans/httpd_tty_comm: Invalid argument
    >> grep: /selinux/booleans/httpd_ssi_exec: Invalid argument
    >> grep: /selinux/booleans/httpd_enable_homedirs: Invalid argument
    >> grep: /selinux/booleans/httpd_enable_cgi: Invalid argument
    >> grep: /selinux/booleans/httpd_unified: Invalid argument
    >> grep: /selinux/disable: Invalid argument
    >> grep: /selinux/commit_pending_bools: Invalid argument
    >> grep: /selinux/context: Invalid argument
    >> grep: /selinux/load: Invalid argument
    >>
    >> I waited at least 30 minutes, and nothing more was printed.
    >> I hit control-C and got a colon prompt and I entered q to quit less.
    >> Tnx,
    >> Charles
    >>
    >>

    >
    > Be careful running 'find' from the root dir. make sure you're
    > logged in as 'root' to do that. 'grep' may hang if any of the
    > files passed to it are 'psuedo files' (files that have no end, they
    > just keep producing data as long as you/grep keep reading from the
    > file, e.g. /dev/zero, etc).
    >
    > Regards,
    > Larry
    >


    Oops, it just 'soaked in' what you are trying to do...

    You must be 'root' when doing a 'find' on the root dir (/), or
    you'll get LOTS of errors.

    You might also want to use the '-mount' option for 'find' to prevent
    scanning remote or mounted dirs. scanning network mounted dirs can
    take forever. Also use the '-type f' option so grep will only 'see'
    regular files, e.g.:

    find / -mount -type f -exec grep 'host\.domain\.com' {} \; -print

    It can take a VERY LONG TIME to 'grep' EVERY file in the system;
    which is what you are trying to do (grep opens and reads EVERY file
    in EVERY directory). It is best to run the 'find' command individually
    on specific dirs (e.g. on /etc, then on /opt, then on /usr, etc, etc).

    Regards,
    Larry

    Regards,
    Larry

    --
    Anti-spam address, change each 'X' to '.' to reply directly.

  4. Re: problem with "find" command

    On Fri, 18 Mar 2005 12:35:22 -0600, a posting issued forth from Charles...
    > I am running Fedora Core 3.
    > This find command worked...
    >
    > [root@host /]# find /etc -exec grep "hsd1" {} \; -print
    > search hsd1.tx.comcast.net.
    > /etc/resolv.conf
    > search hsd1.tx.comcast.net.
    > /etc/sysconfig/networking/profiles/default/resolv.conf
    > search hsd1.tx.comcast.net
    > /etc/resolv.conf.master
    > [root@host /]#
    >
    > This printed 24 lines in the first few seconds and nothing more.
    >
    > [root@host /]# find / -exec grep "host.domain.com" {} \; -print | less
    > grep: /selinux/booleans/allow_ypbind: Invalid argument
    > grep: /selinux/booleans/ypbind_disable_trans: Invalid argument
    > grep: /selinux/booleans/winbind_disable_trans: Invalid argument
    > grep: /selinux/booleans/syslogd_disable_trans: Invalid argument
    > grep: /selinux/booleans/squid_disable_trans: Invalid argument
    > grep: /selinux/booleans/snmpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/postgresql_disable_trans: Invalid argument
    > grep: /selinux/booleans/portmap_disable_trans: Invalid argument
    > grep: /selinux/booleans/ntpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/nscd_disable_trans: Invalid argument
    > grep: /selinux/booleans/named_write_master_zones: Invalid argument
    > grep: /selinux/booleans/named_disable_trans: Invalid argument
    > grep: /selinux/booleans/mysqld_disable_trans: Invalid argument
    > grep: /selinux/booleans/dhcpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/httpd_disable_trans: Invalid argument
    > grep: /selinux/booleans/httpd_tty_comm: Invalid argument
    > grep: /selinux/booleans/httpd_ssi_exec: Invalid argument
    > grep: /selinux/booleans/httpd_enable_homedirs: Invalid argument
    > grep: /selinux/booleans/httpd_enable_cgi: Invalid argument
    > grep: /selinux/booleans/httpd_unified: Invalid argument
    > grep: /selinux/disable: Invalid argument
    > grep: /selinux/commit_pending_bools: Invalid argument
    > grep: /selinux/context: Invalid argument
    > grep: /selinux/load: Invalid argument
    >
    > I waited at least 30 minutes, and nothing more was printed.
    > I hit control-C and got a colon prompt and I entered q to quit less.


    Are you sure the string "host.domain.com" occurs in at least one file on
    a mounted partition?

    As a further followup, is there a reason you aren't doing a

    grep -r host.domain.com /*

    ?

    --
    Jacob
    mailto:`echo wnpbo@urvqre.ubzryvahk.arg | tr [a-z] [n-za-m]`

  5. Re: problem with "find" command

    Larry I Smith wrote:

    > Charles wrote:
    > > I am running Fedora Core 3.
    > >
    > >
    > > This printed 24 lines in the first few seconds and nothing more.
    > >
    > > [root@host /]# find / -exec grep "host.domain.com" {} \; -print | less
    > > grep: /selinux/booleans/allow_ypbind: Invalid argument
    > >
    > > * * * * 30 lines deleted * * * * *
    > >
    > > I waited at least 30 minutes, and nothing more was printed.
    > > I hit control-C and got a colon prompt and I entered q to quit less.
    > > Tnx,
    > > Charles

    >
    > Be careful running 'find' from the root dir. make sure you're
    > logged in as 'root' to do that. 'grep' may hang if any of the
    > files passed to it are 'psuedo files' (files that have no end, they
    > just keep producing data as long as you/grep keep reading from the
    > file, e.g. /dev/zero, etc).
    >
    > Regards,
    > Larry


    Larry,
    Thank you for responding.
    I was not even aware of the existence of pseudo files.
    Does there also exist a grep option to skip these files?
    Perhaps I could use a grep option to skip any file in
    excess of some number of bytes?
    Tnx,
    Charles



  6. Re: problem with "find" command

    Larry I Smith wrote:

    > > Be careful running 'find' from the root dir. make sure you're
    > > logged in as 'root' to do that. 'grep' may hang if any of the
    > > files passed to it are 'psuedo files' (files that have no end, they
    > > just keep producing data as long as you/grep keep reading from the
    > > file, e.g. /dev/zero, etc).
    > >
    > > Regards,
    > > Larry
    > >

    >
    > Oops, it just 'soaked in' what you are trying to do...
    >
    > You must be 'root' when doing a 'find' on the root dir (/), or
    > you'll get LOTS of errors.


    I *AM* running as root.

    > You might also want to use the '-mount' option for 'find' to prevent
    > scanning remote or mounted dirs. scanning network mounted dirs can
    > take forever. Also use the '-type f' option so grep will only 'see'
    > regular files, e.g.:
    >
    > find / -mount -type f -exec grep 'host\.domain\.com' {} \; -print


    When I run the man page on find, the -mount option is not present.
    The -type f option is a good idea.

    > It can take a VERY LONG TIME to 'grep' EVERY file in the system;
    > Regards,
    > Larry


    Agreed! It can take a long time. But after 30 minutes of no response,
    I would think something is wrong.
    Tnx,
    Charles



  7. Re: problem with "find" command

    Charles wrote:
    > Larry I Smith wrote:
    >
    >>>Be careful running 'find' from the root dir. make sure you're
    >>>logged in as 'root' to do that. 'grep' may hang if any of the
    >>>files passed to it are 'psuedo files' (files that have no end, they
    >>>just keep producing data as long as you/grep keep reading from the
    >>>file, e.g. /dev/zero, etc).
    >>>
    >>>Regards,
    >>>Larry
    >>>

    >>Oops, it just 'soaked in' what you are trying to do...
    >>
    >>You must be 'root' when doing a 'find' on the root dir (/), or
    >>you'll get LOTS of errors.

    >
    > I *AM* running as root.
    >
    >>You might also want to use the '-mount' option for 'find' to prevent
    >>scanning remote or mounted dirs. scanning network mounted dirs can
    >>take forever. Also use the '-type f' option so grep will only 'see'
    >>regular files, e.g.:
    >>
    >> find / -mount -type f -exec grep 'host\.domain\.com' {} \; -print

    >
    > When I run the man page on find, the -mount option is not present.
    > The -type f option is a good idea.
    >
    >>It can take a VERY LONG TIME to 'grep' EVERY file in the system;
    >>Regards,
    >>Larry

    >
    > Agreed! It can take a long time. But after 30 minutes of no response,
    > I would think something is wrong.
    > Tnx,
    > Charles
    >
    >


    I took 45 minutes on my pc...

    I'm running SuSE Pro v9.2.
    Here's the output of 'find --version':

    GNU find version 4.1.20

    Here's a snip from 'man find':

    -mount
    Don't descend directories on other filesystems. An alternate name
    for -xdev, for compatibility with some other versions of find.

  8. Re: problem with "find" command

    Spake Charles:
    > I was not even aware of the existence of pseudo files.
    > Does there also exist a grep option to skip these files?


    Nope, because grep takes a list of files. If you asked to scan a file,
    why would you then ask to skip it?

    find, on the other hand, has several options to skip parts of the tree,
    such as -mount.

    Unless you have a second Linux install (unlikely), the device files will
    all be in /dev, /proc and /sys. So why not just tell find to look in
    the top-level directories you *do* want?

    find /home /etc /var /opt /usr -type f PREDICATES

    Incidentally, the device `file' /dev/zero is of type "character
    special", not "file". So the predicate "-type f" will discount it
    before ever grep is run.

    > Perhaps I could use a grep option to skip any file in
    > excess of some number of bytes?


    Not that I know of.

    --
    Trent Buck, Student Errant
    I Adjure Thee, O Foul Demon of The Sinus, by this Leatherman Tool and
    this Fully Earthed 30 Amp Power Strip! Remain Thou within the Faraday
    Cage and Answer the Questions put to Thee, and I shall Discharge Thee
    that Thou mayest return from Whence Thou Camest. -- Peter da Silva

  9. Re: problem with "find" command

    Spake Larry I Smith:
    >>> It can take a VERY LONG TIME to 'grep' EVERY file in the system;

    >> After 30 minutes of no response, I would think something is wrong.

    > I took 45 minutes on my pc...


    You obviously don't have much on your filesystem :-)

    $df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/hde1 7.8G 4.3G 3.1G 59% /
    /dev/hde4 216G 152G 64G 71% /alt
    /dev/hda4 95G 46G 49G 49% /mnt/backup
    /dev/sda2 38G 30G 7.4G 81% /mnt/ipod

    It takes at least an hour to backup /home and /etc to another HDD.

    --
    Trent Buck, Student Errant
    If you can't stand the sociopaths, stay out of the NOC. -- Paul Tomblin

  10. Re: problem with "find" command

    Trent Buck wrote:
    > Spake Larry I Smith:
    >>>>It can take a VERY LONG TIME to 'grep' EVERY file in the system;
    >>>After 30 minutes of no response, I would think something is wrong.

    >>I took 45 minutes on my pc...

    >
    > You obviously don't have much on your filesystem :-)
    >
    > $df -h
    > Filesystem Size Used Avail Use% Mounted on
    > /dev/hde1 7.8G 4.3G 3.1G 59% /
    > /dev/hde4 216G 152G 64G 71% /alt
    > /dev/hda4 95G 46G 49G 49% /mnt/backup
    > /dev/sda2 38G 30G 7.4G 81% /mnt/ipod
    >
    > It takes at least an hour to backup /home and /etc to another HDD.
    >


    >df -h

    Filesystem Size Used Avail Use% Mounted on
    tmpfs 189M 36K 189M 1% /dev/shm
    /dev/hdb4 13G 2.2G 11G 18% /data1
    /dev/hdb3 13G 1.1G 11G 9% /home
    /dev/hda1 9.6G 7.3G 2.3G 77% /windows/C
    /dev/sda4 1019M 17M 1003M 2% /windows/D

    Larry

    --
    Anti-spam address, change each 'X' to '.' to reply directly.

  11. Re: problem with "find" command

    Larry I Smith wrote:
    > Trent Buck wrote:
    >> Spake Larry I Smith:
    >>>>> It can take a VERY LONG TIME to 'grep' EVERY file in the system;
    >>>> After 30 minutes of no response, I would think something is wrong.
    >>> I took 45 minutes on my pc...

    >>
    >> You obviously don't have much on your filesystem :-)
    >>
    >> $df -h
    >> Filesystem Size Used Avail Use% Mounted on
    >> /dev/hde1 7.8G 4.3G 3.1G 59% /
    >> /dev/hde4 216G 152G 64G 71% /alt
    >> /dev/hda4 95G 46G 49G 49% /mnt/backup
    >> /dev/sda2 38G 30G 7.4G 81% /mnt/ipod
    >>
    >> It takes at least an hour to backup /home and /etc to another HDD.
    >>

    >


    Oops, I forgot to include the root (/):

    > >df -h

    > Filesystem Size Used Avail Use% Mounted on
    > tmpfs 189M 36K 189M 1% /dev/shm

    - 13G 3.1G 9G 26% /
    > /dev/hdb4 13G 2.2G 11G 18% /data1
    > /dev/hdb3 13G 1.1G 11G 9% /home
    > /dev/hda1 9.6G 7.3G 2.3G 77% /windows/C
    > /dev/sda4 1019M 17M 1003M 2% /windows/D
    >
    > Larry
    >


    Larry

    --
    Anti-spam address, change each 'X' to '.' to reply directly.

+ Reply to Thread