Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • You don't have to do find and grep. You can pass the parameter to find. find /sys -name "*filesystem*" . Also find searches the filenames. Do you also want to search for content? You should use grep for that. Maybe if you posted your code and the details of your expected output, it would help Commented Apr 12, 2015 at 17:01
  • @rahul Expected output: names of regular files in a given directory (and its subdirectories) which (either in name, directory, or content) have a (sub)string "filesystem", and if they are regular text files, then print the number of the line in them in which said (sub)string occurs. The code I posted was what I had, but you said it was wrong so I guess I'll have to re-do it from a scratch. Commented Apr 12, 2015 at 17:11
  • I'm still a bit confused as to the requirement. Since you mentioned name, directory, or content . What if only the filename matches, what do you want to print then? Does the requirement have to be covered in the same command? Would you mind using find for the file/directory and grep for the content? Commented Apr 12, 2015 at 17:26
  • @rahul I'm okay with using find and grep seperately. The requirement was ambiguous enough and didn't specifically say I have to do it in one command. Commented Apr 12, 2015 at 17:39