If you can see this check that

next section prev section up prev page next page

Using the * wildcard characters with mv, cp, and rm

Wildcard characters are often useful when you want to move or copy multiple files from one directory to another. For example, suppose you have two directories immediately below your current directory, named 'new' and 'old', and these directories contain the following files:

% ls new
myfile myfile2
% ls old
myfile3 myfile4

To move all the files from the directory 'new' into the directory 'old', we would type:

% mv new/* old
% ls new             ( no files in new)
% ls old             ( all files are now in old)
myfile myfile2 myfile3 myfile4

We can do a similar operation with the cp command. For example, to copy all the files from old into new, we could type:

% cp old/* new

Similarly, we can use wildcard characters with the rm command. For example, to remove all of the files in the directory new, type:

% rm new/*
% ls new             ( all the files are now gone )

Warning: be careful when using wildcard that you do not accidentally remove or move files that you need.


Linux tutorials: intro1 intro2 wildcard permission pipe vi essential admin net SELinux1 SELinux2 fwall DNS diag Apache1 Apache2 Mail
Caine 6.0: Essentials | Basic | Search | SysIntro | 5a | 5b | 5c | 6 | 7a | 7b | 8a | 8b | WebBrowserA | WebBrowserB | Registry | Browser
Digital Investigation: Editing | Email | Logs | Strength
Kali: 1a | 1b | 1c | 2 | 3 | 4a | 4b | 5 | 6 | 7a | 8a | 8b | 9 | 10 |
Useful: Quiz | Forums | Privacy Policy | Terms and Conditions
Site Links:XMLZoo ActiveSQL ProgZoo SQLZoo

Linuxzoo created by Gordon Russell.
@ Copyright 2004-2017 Edinburgh Napier University