Results 1 to 6 of 6

Thread: refine find search

  1. #1
    Join Date
    Jul 2011
    Beans
    19

    refine find search

    hey i'm looking for a file and when i use a find search i am getting too much information to sift through. i am only looking for a .txt file but and getting a lot of .deb files, how do i refine the search to only look for .txt files?

    if it helps what im putting in is "find REQUIRED /home/user/../../var/cache/apt/archives/"

    where of course user is my name

  2. #2
    Join Date
    Oct 2009
    Beans
    Hidden!
    Distro
    Ubuntu 22.04 Jammy Jellyfish

    Re: refine find search

    Why are you searching in /var/cache/apt/archives/ ?

    Code:
    find /path/to/directory -name filename.txt -print
    Come to #ubuntuforums! We have cookies! | Basic Ubuntu Security Guide

    Tomorrow's an illusion and yesterday's a dream, today is a solution...

  3. #3
    Join Date
    Jan 2010
    Location
    Sydney, Australia
    Beans
    Hidden!
    Distro
    Ubuntu

    Re: refine find search

    Quote Originally Posted by nathanv221 View Post
    hey i'm looking for a file and when i use a find search i am getting too much information to sift through. i am only looking for a .txt file but and getting a lot of .deb files, how do i refine the search to only look for .txt files?

    if it helps what im putting in is "find REQUIRED /home/user/../../var/cache/apt/archives/"

    where of course user is my name
    The below would look for only .txt files in the /path/to/search directory .

    Code:
    find /path/to/search -name "*.txt" -print
    <edit>Sorry for the redundant post , guess me and charlsea were minutes apart .

    However i want to add something for your help , in a find search if you can not remember the exact file name you can always use wildcards and wrap them in double quotes as above .
    </edit>
    Last edited by codemaniac; June 20th, 2012 at 07:30 PM.
    “Progress is made by lazy men looking for easier ways to do things”
    — Robert A. Heinlein

  4. #4
    Join Date
    May 2009
    Location
    Courtenay, BC, Canada
    Beans
    1,661

    Re: refine find search

    you can also pipe to other tools which can give you better or simpler filtering options, such as grep or sed
    Code:
    find / -type f 2>/dev/null | grep -iE '.*[0-9]*|\.avfilter|etc\..*$'

  5. #5
    Join Date
    Feb 2008
    Beans
    251
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: refine find search

    Might be better to use the -iname flag... just in case the file has the extension .TXT:

    find /path/to/files/ -iname "*.txt"

    then filter your results with grep:

    find /path/to/files/ -iname "*.txt" | grep -i <thing you're looking for>

    What are you looking for in /var/cache/apt/archives/ ?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •