![]() ![]() The strange thing is that it works correctly only for the last pattern. The concept is very similar to that of excluding files, except we use the -exclude-dir option and name the directories to ignore. Otherwise, use the -exec primary of find. If your grep supports the -r or -R option for recursive search, use it. Grep is a Unix utility that searches through either information piped to it or files in the current directory. What's going wrong here is that you have a file whose name must be quoted on input to xargs (probably containing a ' ). By default,ACTION is read, i.e., read directories. 24 xargs expects input in a format that no other command produces, so it's hard to use effectively. ![]() The 1st grep actually give me the correct list of paths (any text files containing $string), but the 2nd grep doesn't filter as expected since $out contains all the items produced by the 1st grep except the occurrences corresponding the last pattern. From man grep: -d ACTION, -directoriesACTION If an input file is a directory, use ACTION to process it. Discards output of non directories (such as /proc/) grep 0-9.+G. What I've done follows, but it didn't worked (the various options are required for other reasons): grep -nriFlI "$string" "/test" | grep -vFf "$to_skip" > "$out" Shows the directory and the sizes of each in a human readable format. You can use or or whatever your shell allows as placeholder. This "exclusion list" contains both files and folder paths as shown below: /test/ex1/fileA 4 Answers Sorted by: 14 Just add all files on the command line. Inside /test, I want to iterate only text files containing a particular string ( $string), ignoring files and entire directories specified in a file ( $to_skip) by path. ![]() I have a folder ( /test) that contains several subfolder and files (at various level). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |