How can I use inverse or negative wildcards when pattern matching in a unix/linux shell?

前端 未结 11 1605
梦如初夏
梦如初夏 2020-11-22 13:50

Say I want to copy the contents of a directory excluding files and folders whose names contain the word \'Music\'.

cp [exclude-matches] *Music* /target_direc         


        
11条回答
  •  逝去的感伤
    2020-11-22 14:22

    Not in bash (that I know of), but:

    cp `ls | grep -v Music` /target_directory
    

    I know this is not exactly what you were looking for, but it will solve your example.

提交回复
热议问题