Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    searching for a phrasse in files and outputting file path to a file

    Hi, i want to make my bash script search for this phrasse:

    in all files smaller than 2000kb in /home and output their full paths into file ./result

    so i have this:

    find /home -type f -size -2000k -print | xargs grep *"$phrasse"* -ls -exec "pwd;ls -lah >> ./result" {} \;
    But when i execute that command, it start listing alot of files on the screen as the search goes, but these files dont contain the phrasse i want to search. Please what is wrong in my command? (i want to run it as a cronjob)

    thank you in advance for any help

  2. #2
    use find's built-in exec capability instead, e.g.:

    find /home -type f -size -2000k -exec grep -l "$phrasse" {} \; >> ./result

Posting Permissions

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