简体   繁体   中英

shell script Move and Copy

I have a folder named rules in

/srv/www/htdocs/downloads

and I have another folder with the same name rules in here:

/srv/www/htdocs/didebansnort/core/snort/

I want to copy the folder rules in upper one to the second path

Also I want to know what is the syntax for moving?

the same that you use when you copy/move things in shell. That's why they called shell scripts:)

Copying (from -> to)

cp -r /srv/www/htdocs/downloads/rules /srv/www/htdocs/didebansnort/core/snort/rules

we use cp -r to copy directory (r stands for recursive) and simple cp for copying of a single file.

Moving (from -> to)

mv /srv/www/htdocs/downloads/rules /srv/www/htdocs/didebansnort/core/snort/rules

This is for nix/mac/cygwin

PS While in the shell you can simply type in this to get a complete manual:

man command_name

If the directory /srv/www/htdocs/didebansnort/core/snort/rules is not empty you cannot just move /srv/www/htdocs/downloads/rules to /srv/www/htdocs/didebansnort/core/snort . You'll either need to delete the existing directory or devise some merging strategy. Fore example, copying over cp -r /srv/www/htdocs/downloads/rules /srv/www/htdocs/didebansnort/core/snort/rules (as nix showed) will result in overwriting all duplicate files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM