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

前端 未结 11 1691
梦如初夏
梦如初夏 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:15

    this would do it excluding exactly 'Music'

    cp -a ^'Music' /target
    

    this and that for excluding things like Music?* or *?Music

    cp -a ^\*?'complete' /target
    cp -a ^'complete'?\* /target
    

提交回复
热议问题