0
 grep --exclude=\*.{mp3,jpg,pdf,png} -i "size\|log" | cut -c 32-|grep -v name1 |grep -v name2

it's not working for me i want to do something like

ls -la |  grep --exclude=\*.{mp3,jpg,pdf,png} -i "size\|log" | cut -c 32-|grep -v name1 |grep -v name2

but it's not excluding those extensions

ls -la |  grep -i "size\|log" | cut -c 32-|grep -v name1 |grep -v name2 |grep -v "*.mp3"

is not working

the -r flag gives me the result but with the content of the file, i just wanna grep filename

KillRoy27
  • 17
  • 4
  • 2
    `--exclude` is for grep to ignore files, not lines; are you looking for `grep -v` functionality? – Benjamin W. Mar 23 '21 at 17:01
  • 2
    It looks like `find` might be a better match for what you're doing. – Benjamin W. Mar 23 '21 at 17:03
  • 1
    Also, please take a look at: [Why not parse `ls`](https://unix.stackexchange.com/questions/128985/why-not-parse-ls-and-what-to-do-instead) – 0stone0 Mar 23 '21 at 17:05
  • @BenjaminW. yep, -v functionality. allready using it |grep -v "*.mp3" but it is not working – KillRoy27 Mar 23 '21 at 17:10
  • grep takes a regex, not glob. Use `grep -v '.*\.mp3'`. But that matching `.*` is useless, just match `.mp3` - `grep -v '\.mp3'` – KamilCuk Mar 23 '21 at 18:30
  • If you show a list of files in the current directory and the output you'd like to have, we probably can suggest a robust solution. – Benjamin W. Mar 23 '21 at 19:40

0 Answers0