![]() If you revile regexs and want just simple strings (and are therefore more sane than I), change 'grep -Ef' above to 'grep -f': % cat patterns.txt You can make a pattern file containing whatever patterns are legal extended regexs, which includes simple strings which don't contain special regex characters. Here is the empty "target" directory: % ls. Here is a test "source" directory: % ls -1 source The example below includes an extended regex pattern (the first line in the file) which I actually used to do a similar operation: moving files that end in patterns like _9.mpg to a different directory:Ĭaveat: To make spaces play nice for files with spaces in them (and who doesn't have spaces in their filenames, eh?), I'm using this hack, which will cause bash to split pipes between commands on newlines, instead of spaces: OLD_IFS=$IFS As a bonus, it's resilient with respect to filenames that contain spaces (but not all weird filenames), and allows patterns to be extended regexs instead of only simple fixed strings. On MacOS (10.13: High Sierra), and using bash (I tested the MacOS-supplied one and GNU bash 4.4.19), the following does what you need. Evidently, BSD find doesn't like -printf, and BSD grep doesn't like -z. The first answer pointed me in the right direction, but sadly (or not?) I am on MacOS. My problem was very similar you yours, but I wanted to use a regex to match the files to be operated on. This will open a search panel where you can enter your search criteria.I am on MacOS. To search for files and directories using the common file app, you can use the search box in the toolbar or press Ctrl+F. You can also use keyboard shortcuts or drag-and-drop to perform various actions on your files and directories. You can navigate through your file system using the sidebar, toolbar, or breadcrumbs. These apps allow you to browse and search your files and directories using a familiar window-based interface. This might be called Nautilus, Files, or File Manager, depending on whether you’re using Ubuntu or another Linux distribution. If you prefer a graphical interface for finding files and directories in Linux, you can use the file management app that’s included with your Linux distribution. For example, -l 10 linux shows only the first 10 files that contain linux in their names.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |