Large variable in bash script, is it wise?


Results 1 to 3 of 3

Thread: Large variable in bash script, is it wise?

Hybrid View

  1. #1
    Join Date
    Apr 2014
    Posts
    34

    Lightbulb Large variable in bash script, is it wise?

    Hello,

    in my script i need to find newly added files added accross server HDD and check if they contains certain phrasses (30 phrasses)
    so i made something like following code, but i dont know if its wise that find command in variable (it can match like tens of thousand file paths..), or how would you do it better to be less performance hungry..? thank you

    for filepath in $(find /home ***);do
    for phrasse in $(cat phrasses);do
    grepout=$(grep ***)
    if [[ "$grepout" == *"some phrasse"* ]];then
    echo "phrasse found in $filepath"
    fi
    done
    done

  2. #2
    Join Date
    Nov 2014
    Location
    South Africa
    Posts
    16
    why not limit the search to a date range

    start_date=201105040000

    end_date=201105042359

    touch -t ${start_date} start

    touch -t ${end_date} end

    find /you/path -type f -name '*you*pattern*' -newer start ! -newer end -exec ls -s {} \;

    Second one: find files modified between 20 and 21 days ago:

    find -ctime +20 -ctime -21

    finds files modified between 2500 and 2800 minutes ago:

    find -cmin +2500 -cmin -2800

  3. #3
    Join Date
    Apr 2014
    Posts
    34
    Thx, im using something like what You suggestedin the "find" command, but still there are quite alot of results (im searching thru around 15 linux filesystems), thats why im sking what im asking.. if my script is issue (too alrge variable) or how can i do it elseway?

Posting Permissions

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