![]() Here i am reading the files by giving the path to them and whatever i am reading i am keeping them inside a variable I, which i will quote at a later point while processing it to preserve the spaces so as to process it correctly. SCRIPT : find /path/to/files/ -iname "*jpg" | \ The pattern is matched against the file base name, excluding the directory. This is one of the basic ways of doing it, however, the other answers provided by the other people here work just as well. Multiple patterns can be specified using a list. We here will read all the files present and keep them in a variable, next time when doing the desired processing we just will have to keep that variable inside quotes which will preserve the file names with spaces. To find all the files of a certain extension within the current path you can use the following find syntax. Solution : So one of the better known ways of doing this is to do a clean read. means search in current directory, but you could specify another path and find will descend into that directory and subdirectories, to search recursively. If you absolutely want to use regex simply use find -regex '.\.\ (xls\csv\)' Share Follow answered at 16:01 Joachim Sauer 1,370 1 8 5 9 Better answer than mine. We find all the files with txt and rtf extensions here and give them all as parameters to grep. find searches recursively in all the directories below the given path. 2 Answers Sorted by: 125 Why not simply use this: find -name '.xls' -o -name '.csv' You don't need regex for this. at the start denotes the current directory. Find All Files With an Extension in Bash Finding files with a particular extension is an easy operation in Bash. ![]() type f -name '.txt' This will list all files with the extension. When it opens, run the command below: find. So they don't understand that they need to handle spaces as well, as the file name can consist of 2 or more words with spaces. Just press Ctrl Alt T on your keyboard to open Terminal. log extension and order by file size Ask Question Asked 6 years, 4 months ago Modified 1 year, 5 months ago Viewed 58k times 9 I'm using CentOS 6.8 I'd like to know if I can I find all files with the. Sometimes, people with limited knowledge and having a misconception of file and folder structure tend to forget that " In UNIX Everything is a file". What you have mentioned is one of the basic problems that people face, when they try to read file names. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |