Copy Files Using Wildcards


cp *

It's time for more laziness, namely, the capability to copy several files at one time into a directory using wildcards. If you've been careful naming your files, this can be a really handy timesaver because you can exactly specify a group of files.

$ pwd /home/scott/libby $ ls ~/pix arrowrock.jpg  by_pool_03.jpg on_floor_03.jpg by_pool_01.jpg on_floor_01.jpg on_floor_04.jpg by_pool_02.jpg on_floor_02.jpg $ ls arrowrock.jpg libby.jpg libby_on_couch.jpg $ cp ~/pix/by_pool*.jpg . $ ls arrowrock.jpg by_pool_02.jpg on_couch.jpg by_pool_01.jpg by_pool_03.jpg libby.jpg 


You aren't limited to the * wildcard; instead, you can more precisely identify which files you want to copy using a bracket that matches any characters named between the [ and ] characters. If you want to copy the first three on_floor pictures but not the fourth, that's easily done with cp.

$ pwd /home/scott/libby $ ls ~/pix arrowrock.jpg by_pool_03.jpg on_floor_03.jpg by_pool_01.jpg on_floor_01.jpg on_floor_04.jpg by_pool_02.jpg on_floor_02.jpg $ ls arrowrock.jpg libby.jpg libby_on_couch.jpg $ cp ~/pix/on_floor_0[1-3].jpg . $ ls arrowrock.jpg  libby_on_couch.jpg  on_floor_02.jpg libby.jpg      on_floor_01.jpg     on_floor_03.jpg 




Linux Phrasebook
Linux Phrasebook
ISBN: 0672328380
EAN: 2147483647
Year: 2007
Pages: 288

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net