Tuesday, May 7, 2024
 Popular · Latest · Hot · Upcoming
22
rated 0 times [  22] [ 0]  / answers: 1 / hits: 48441  / 2 Years ago, fri, september 16, 2022, 5:40:11

I have a directory with over 1000 files, and a few of them are .zip files, and I want to turn them all into .tgz files.



I want to use grep to make a list of file names. I have tried "grep *.zip" to no avail. Reading the man pages, I thought that * was a universal selector. Why is this not working?



Thank you.


More From » grep

 Answers
7

You should really use find instead.


find <dir> -iname *.zip

Example: to search for all .zip files in current directory and all sub-directories try this:


find . -iname *.zip


This will list all files ending with .zip regardless of case. If you only want the ones with lower-case change -iname to -name


The command grep searches for strings in files, not for files. You can use it with find to list all your .zip files like this


find . |grep -e ".zip$"

[#40858] Saturday, September 17, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
bleger

Total Points: 468
Total Questions: 108
Total Answers: 100

Location: Belarus
Member since Wed, Dec 7, 2022
1 Year ago
bleger questions
Wed, Mar 1, 23, 03:00, 1 Year ago
Mon, Feb 6, 23, 14:44, 1 Year ago
Wed, Dec 29, 21, 13:59, 2 Years ago
;