🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 80 (from laksa126)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

🚫
NOT INDEXABLE
CRAWLED
6 months ago
🚫
ROBOTS BLOCKED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffFAILdownload_stamp > now() - 6 MONTH6.3 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://www.cyberciti.biz/faq/copy-command/
Last Crawled2025-10-03 16:22:59 (6 months ago)
First Indexed2016-11-18 17:53:55 (9 years ago)
HTTP Status Code200
Meta TitleLinux Copy File Command [ cp Command Examples ] - nixCraft
Meta DescriptionLinux copy file command and examples: Explains how to copy file under Linux / UNIX / BSD operating system using cp command.
Meta Canonicalnull
Boilerpipe Text
H ow do I copy files under Linux operating systems? How do I make 2nd copy of a file on a Linux bash shell? How can I copies files and directories on a Linux? To copy files and directories use the cp command under a Linux, UNIX-like, and BSD like operating systems. cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name. cp Command Syntax The syntax is as follows to copy files and directories using the cp command: $ cp SOURCE DEST $ cp SOURCE DIRECTORY $ cp SOURCE1 SOURCE2 SOURCE3 SOURCEn DIRECTORY $ cp [OPTION] SOURCE DEST $ cp [OPTION] SOURCE DIRECTORY Where, In the first and second syntax you copy SOURCE file to DEST file or DIRECTORY. In the third syntax you copy multiple SOURCE(s) (files) to DIRECTORY. Note: You need to type the cp command at the dollar sign ($) prompt. This prompt means that the shell is ready to accept your typed commands. Do not type the dollar ($) sign. You need to open the Terminal app to use cp command on a Linux. Linux Copy File Examples To make a copy of a file called file.doc in the current directory as newfile.doc, enter: $ cp file.doc newfile.doc $ ls -l *.doc Sample outputs: -rw-r--r-- 1 veryv wheel 20 Mar 20 17:42 file.doc -rw-r--r-- 1 veryv wheel 20 Mar 20 17:43 newfile.doc You can copy multiple files simultaneously into another directory. In this example, copy the files named main.c, demo.h and lib.c into a directory named backup in the current directory: $ cp main.c demo.h lib.c backup If backup is located in /home/project/ directory or folder, then use full path as follows: $ cp main.c demo.h lib.c /home/project/backup/ Copy a file to another directory To copy a file from your current directory into another directory called /tmp/, enter: $ cp filename /tmp $ ls /tmp/filename $ cd /tmp $ ls $ rm filename Verbose option To see files as they are copied pass the -v option as follows to the cp command: $ cp -v filename.txt filename.bak $ cp -v foo.txt /tmp Here is what I see: foo.txt -> /tmp/foo.txt Preserve file attributes To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter: $ cp -p file.txt /dir1/dir2/ $ cp -p filename /path/to/new/location/myfile This option ( -p ) forces cp to preserve the following attributes of each source file in the copy as allowed by permissions: Modification time/date Access time File flags File mode User ID (UID) Group ID (GID) Access Control Lists (ACLs) Extended Attributes (EAs) Copying all files The star wildcard represents anything i.e. all files. To copy all the files in a directory to a new directory, enter: $ cp * /home/tom/backup The star wildcard represents anything whose name ends with the .doc extension. So, to copy all the document files (*.doc) in a directory to a new directory, enter: $ cp *.doc /home/tom/backup Recursive copy To copy a directory, including all its files and subdirectories, to another directory, enter (copy directories recursively): $ cp -R * /home/tom/backup Linux copy file command with interactive option You can get prompt before overwriting file. For example, if it is desired to make a copy of a file called foo and call it bar and if a file named bar already exists, the following would prompt the user prior to replacing any files with identical names: $ cp -i foo bar Verbose output with cp command If you pass the -v to the cp, it makes tells about what is going on. That is verbose output: $ cp -v file1 file2 $ cp -avr dir2 /backups/ Archive option You copy directories/files recursively while preserve the specified attributes such as file mode, ownership, timestamps, and all other possible option as follows: $ cp -dR --preserve=all ~/project/app1/ /nfs/backups/project/ ## OR ## $ cp -a ~/project/app1/ /nfs/backups/project/ Conclusion This page explained cp command that is used for copying files under Linux and Unix-like systems. For more info see man pages using the help command or man command as follows: $ man cp $ man ls $ cp --help 🥺 Was this helpful? Please add a comment to show your appreciation or feedback . Vivek Gite is an expert IT Consultant with over 25 years of experience, specializing in Linux and open source solutions. He writes about Linux, macOS, Unix, IT, programming, infosec, and open source. Follow his work via RSS feed or email newsletter .
Markdown
[![nixCraft](https://www.cyberciti.biz/media/new/faq/2017/06/new-nixcraft-logo-cyberciti.biz_.png)](https://www.cyberciti.biz/faq/) [nixCraft](https://www.cyberciti.biz/) → [Howto](https://www.cyberciti.biz/faq/) → [BASH Shell](https://www.cyberciti.biz/faq/category/bash-shell/) → Linux Copy File Command \[ cp Command Examples \] # [Linux Copy File Command \[ cp Command Examples \]](https://www.cyberciti.biz/faq/copy-command/) Author: Vivek Gite Last updated: April 6, 2023 [37 comments](https://www.cyberciti.biz/faq/copy-command/#comments) [![See all GNU/Linux related FAQ](https://www.cyberciti.biz/media/new/category/old/linux-logo.png)](https://www.cyberciti.biz/faq/category/linux/ "See all GNU/Linux related FAQ") How do I copy files under Linux operating systems? How do I make 2nd copy of a file on a Linux bash shell? How can I copies files and directories on a Linux? To copy files and directories use the cp command under a Linux, UNIX-like, and BSD like operating systems. cp is the command entered in a Unix and Linux shell to copy a file from one place to another, possibly on a different filesystem. The original file remains unchanged, and the new file may have the same or a different name. | Tutorial details | | |---|---| | Difficulty level | [Easy](https://www.cyberciti.biz/faq/tag/easy/ "See all Easy Linux / Unix System Administrator Tutorials") | | Root privileges | No | | Requirements | Linux terminal | | Category | [File Management](https://www.cyberciti.biz/faq/copy-command/#File_Management "See ALL other tutorials in 'File Management' category") | | OS compatibility | [AIX](https://www.cyberciti.biz/faq/copy-command/) • AlmaLinux • [Alpine](https://www.cyberciti.biz/faq/category/alpine-linux/ "See all Alpine Linux tutorials") • [Arch](https://www.cyberciti.biz/faq/category/arch-linux/ "See all Arch Linux tutorials") • BSD • [Debian](https://www.cyberciti.biz/faq/category/debian-ubuntu/ "See all Debian Linux tutorials") • [Fedora](https://www.cyberciti.biz/faq/category/fedora-linux/ "See all Fedora Linux Enterprise tutorials") • [HP-UX](https://www.cyberciti.biz/faq/category/hp-ux-unix/ "See all HP-UX Unix tutorials") • [macOS](https://www.cyberciti.biz/faq/category/mac-os-x/ "See all macOS (OS X) tutorials") • Mint • [openSUSE](https://www.cyberciti.biz/faq/tag/opensuse/ "See all openSUSE Linux Enterprise tutorials") • Pop!\_OS • [RHEL](https://www.cyberciti.biz/faq/category/redhat-and-friends/ "See all RHEL (Red Hat Enterprise Linux) tutorials") • Rocky • [Stream](https://www.cyberciti.biz/faq/tag/centos-stream/ "See all CentOS Stream Linux tutorials") • [SUSE](https://www.cyberciti.biz/faq/category/suse/ "See all SUSE Linux Enterprise tutorials") • [Ubuntu](https://www.cyberciti.biz/faq/category/ubuntu-linux/ "See all Ubuntu Linux tutorials") • [Unix](https://www.cyberciti.biz/faq/category/unix/ "See all Unix tutorials") • WSL | | Est. reading time | 4 minutes | ## cp Command Syntax The syntax is as follows to copy files and directories using the cp command: Where, - In the first and second syntax you copy SOURCE file to DEST file or DIRECTORY. - In the third syntax you copy multiple SOURCE(s) (files) to DIRECTORY. ***Note:*** You need to type the cp command at the dollar sign (\$) prompt. This prompt means that the shell is ready to accept your typed commands. Do not type the dollar (\$) sign. You need to open the Terminal app to use cp command on a Linux. ## Linux Copy File Examples To make a copy of a file called file.doc in the current directory as newfile.doc, enter: Sample outputs: ``` -rw-r--r-- 1 veryv wheel 20 Mar 20 17:42 file.doc -rw-r--r-- 1 veryv wheel 20 Mar 20 17:43 newfile.doc ``` You can copy multiple files simultaneously into another directory. In this example, copy the files named main.c, demo.h and lib.c into a directory named backup in the current directory: `$ cp main.c demo.h lib.c backup` If backup is located in /home/project/ directory or folder, then use full path as follows: `$ cp main.c demo.h lib.c /home/project/backup/` ### Copy a file to another directory To copy a file from your current directory into another directory called /tmp/, enter: ### Verbose option To see files as they are copied pass the `-v` option as follows to the cp command: Here is what I see: ``` foo.txt -> /tmp/foo.txt ``` ### Preserve file attributes To copy a file to a new file and preserve the modification date, time, and access control list associated with the source file, enter: This option (`-p`) forces cp to preserve the following attributes of each source file in the copy as allowed by permissions: 1. Modification time/date 2. Access time 3. File flags 4. File mode 5. User ID (UID) 6. Group ID (GID) 7. Access Control Lists (ACLs) 8. Extended Attributes (EAs) ### Copying all files The star wildcard represents anything i.e. all files. To copy all the files in a directory to a new directory, enter: `$ cp * /home/tom/backup` The star wildcard represents anything whose name ends with the .doc extension. So, to copy all the document files (\*.doc) in a directory to a new directory, enter: `$ cp *.doc /home/tom/backup` ### Recursive copy To copy a directory, including all its files and subdirectories, to another directory, enter (copy directories recursively): `$ cp -R * /home/tom/backup` ## Linux copy file command with interactive option You can get prompt before overwriting file. For example, if it is desired to make a copy of a file called foo and call it bar and if a file named bar already exists, the following would prompt the user prior to replacing any files with identical names: `$ cp -i foo bar` ## Verbose output with cp command If you pass the `-v` to the cp, it makes tells about what is going on. That is verbose output: ![Linux Copy File Command Examples](https://www.cyberciti.biz/media/new/faq/2006/05/Linux-Copy-File-Command-Examples.png) ## Archive option You copy directories/files recursively while preserve the specified attributes such as file mode, ownership, timestamps, and all other possible option as follows: ## Conclusion This page explained cp command that is used for copying files under Linux and Unix-like systems. For more info see man pages using the [help command](https://bash.cyberciti.biz/guide/Help_command "help command - Linux Bash Shell Scripting Tutorial Wiki") or [man command](https://bash.cyberciti.biz/guide/Man_command "Man command - Linux Bash Shell Scripting Tutorial Wiki") as follows: 🥺 Was this helpful? Please add [a comment to show your appreciation or feedback](https://www.cyberciti.biz/faq/copy-command/#respond "Please add your comment below ↓ to show your appreciation or feedback to the author"). [Vivek Gite](https://www.vivekgite.com/) is an expert IT Consultant with over 25 years of experience, specializing in Linux and open source solutions. He writes about Linux, macOS, Unix, IT, programming, infosec, and open source. Follow his work via [RSS feed](https://www.cyberciti.com/atom/atom.xml "Get nixCraft updates using RSS feed") or [email newsletter](https://newsletter.cyberciti.com/subscription?f=1ojtmiv8892KQzyMsTF4YPr1pPSAhX2rq7Qfe5DiHMgXwKo892di4MTWyOdd976343rcNR6LhdG1f7k9H8929kMNMdWu3g "Get nixCraft updates using Email"). 37 comments… [add one](https://www.cyberciti.biz/faq/copy-command/#respond) - Genami Lakau Jun 5, 2010 @ 23:33 My Oracle runs on UNIX plat form. It could be best to know the basiz linus command. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-47655) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-47655 "permalink to this comment") - Anonymous Jun 5, 2010 @ 23:34 I would like to know the basic UNIX / LINUS commands. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-47656) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-47656 "permalink to this comment") - loki2441 Sep 4, 2010 @ 8:27 cp -v file.doc{,.bak} will also be good [↩](https://www.cyberciti.biz/faq/copy-command/#comment-49207) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-49207 "permalink to this comment") - milind dhuri Aug 22, 2011 @ 8:15 sir i am having server where user are created in home partition i want to copy one file to eache users desktop wheather i.e. possible with one command of cp if somebody knows please mail me [↩](https://www.cyberciti.biz/faq/copy-command/#comment-61776) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-61776 "permalink to this comment") - adsf Mar 14, 2012 @ 22:52 actually this is wrong. It doesn’t copy subdirectories To copy all the files in a directory to a new directory, enter: \$ cp \* /home/tom/backup [↩](https://www.cyberciti.biz/faq/copy-command/#comment-68390) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-68390 "permalink to this comment") - Magesh M Mar 20, 2013 @ 12:21 Today i have copyed all the files and folder to new directory using below commands \$ cp -R \* /home/tom/backup \$ cp \* /home/tom/backup [↩](https://www.cyberciti.biz/faq/copy-command/#comment-83074) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-83074 "permalink to this comment") - sophea Oct 18, 2013 @ 4:53 Dear all, I want to copy folder1 to folder2 folder3 folder4 folder5… so what the command line should i type in a single line? Thanks [↩](https://www.cyberciti.biz/faq/copy-command/#comment-99396) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-99396 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [nixCraft](https://www.vivekgite.com/) Oct 18, 2013 @ 7:16 ``` cp -avr folder{1,2,3,4,5} /path/to/dest ``` OR ``` cp -avr folder* /path/to/dest ``` OR ``` cp -avr folder1 folder2 folderN /path/to/dest ``` Read the cp syntax for more info. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-99406) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-99406 "permalink to this comment") - sophea Feb 25, 2014 @ 3:38 Dear NixCraf, Its not mean that. suppose i have one folder named folder1 but i need 6-more folder. usually i type command as bellow to do my job, cp folder1 folder2 cp folder1 folder3 cp folder2 folder3 …. i don’t want to use for-loop so, have any option in cp command to do that? thanks for your reply sophea [↩](https://www.cyberciti.biz/faq/copy-command/#comment-121021) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-121021 "permalink to this comment") - amol Feb 4, 2014 @ 6:39 what is meanning of cp -b command?? [↩](https://www.cyberciti.biz/faq/copy-command/#comment-115478) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-115478 "permalink to this comment") - ray Nov 4, 2014 @ 18:03 If you need helping with the copy command (CP)…. At the command line (CLI)… type: cp –help This will display the list of switches used on how to copy. It also shows the format on how to copy single, multiple files and directories. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-371151) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-371151 "permalink to this comment") - sarmaji Apr 13, 2014 @ 16:14 How to avoid the overwriting of the file while copying if the file is already existing ? [↩](https://www.cyberciti.biz/faq/copy-command/#comment-128100) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-128100 "permalink to this comment") - [Nix Craft](https://www.vivekgite.com/) Apr 14, 2014 @ 13:56 `cp -i file dest` See -i option. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-128200) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-128200 "permalink to this comment") - Enric Oct 30, 2015 @ 14:04 cp -n files\* /path this copies all the files who’s name differ and skips the already existing ones. It does neither ask nor raise an error if one is already there. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-756831) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-756831 "permalink to this comment") - NHK Jul 16, 2014 @ 12:49 Hi dear, I want to know how to create schedule copy script on red hat Linux. I mean database server to backup server. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-224686) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-224686 "permalink to this comment") - Gil Oct 28, 2014 @ 15:32 How does this command know what directory you are saving the newly copied file too? Where is that in the below example? \$ cp filename /tmp \$ ls /tmp/filename \$ cd /tmp \$ ls \$ rm filename [↩](https://www.cyberciti.biz/faq/copy-command/#comment-355600) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-355600 "permalink to this comment") - Insider Mar 20, 2015 @ 11:34 If i have stored the path in variable e.g path= /folder/xyz/ cp off.doc \$path it is giving error.. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-611924) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-611924 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [nixCraft](https://www.vivekgite.com/) Mar 20, 2015 @ 12:08 No gap between variable and value. Also avoid using variable called path. Use something like p: ``` ## assuming that you are using bash/sh/ksh shell ## p="/folder/xyz" echo "$p" cp -v off.doc "$p" ``` [↩](https://www.cyberciti.biz/faq/copy-command/#comment-611959) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-611959 "permalink to this comment") - Sergei Apr 21, 2015 @ 15:29 hi, Can I copy file which is constantly written? Will it harm the original somehow? [↩](https://www.cyberciti.biz/faq/copy-command/#comment-647465) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-647465 "permalink to this comment") - Suresha Jan 8, 2016 @ 13:42 Can we copy files (1.txt, 2.txt etc.,) from a all the sub directiries to one folder (see below). eg: Test—\>test1, test2… each of test1 folder has \*.txt file Main Directory = Test Sub Directorty Name within Test = test1, test2 etc., Each Sub directory has a text file = 1.txt (in test1 folder) and 2.txt (in test2 folder) [↩](https://www.cyberciti.biz/faq/copy-command/#comment-773654) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-773654 "permalink to this comment") - Naresh Jan 16, 2017 @ 14:06 Hi There, If i want to copy a single file into three locations, by using a single command. Would that be possible? If yes, please provide the command. Thanks, Naresh [↩](https://www.cyberciti.biz/faq/copy-command/#comment-911046) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-911046 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [Vivek Gite](https://www.vivekgite.com/) Jan 16, 2017 @ 15:58 `echo /location1/ /location2 /location3/ | xargs -n 1 cp myfileName` [↩](https://www.cyberciti.biz/faq/copy-command/#comment-911048) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-911048 "permalink to this comment") - srishti Jan 24, 2017 @ 11:44 i want to copy all file less then -800kb [↩](https://www.cyberciti.biz/faq/copy-command/#comment-911114) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-911114 "permalink to this comment") - Daniel Dec 15, 2017 @ 18:18 I have two virtual linux machines. How to copy from one to another.. In other words how to refer the machinename/adress/filename of the source file [↩](https://www.cyberciti.biz/faq/copy-command/#comment-929932) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-929932 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [Vivek Gite](https://www.vivekgite.com/) Dec 15, 2017 @ 18:21 Use scp command to copy files between two machines/vms/servers. Copy a file named foo from server named bar using a user named vivek: `laptop$ scp vivek@bar:/home/vivek/foo/ /tmp` [↩](https://www.cyberciti.biz/faq/copy-command/#comment-929934) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-929934 "permalink to this comment") - Daniel Sema Vyteck Sep 30, 2022 @ 14:46 Let your 2 Linux machines be LinixA and LinuxB respectively, and you want to copy FILE\_1 from LinuxA to LinuxB. 1) First you need to make both machines be able to communicate via ssh. 2) create user\_1 in both machines. 3) Log in to LinuxA and run the command:- `scp FILE_1 user_1@LinuxB:/.` 4) Log in to machine LinuxB to see your FILE\_1 in the root (/) directory. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-943330) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-943330 "permalink to this comment") - Anupam Sep 21, 2020 @ 7:40 Thanks – this was helpful [↩](https://www.cyberciti.biz/faq/copy-command/#comment-932547) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-932547 "permalink to this comment") - jenny Oct 6, 2020 @ 10:04 Hi do you know how to copy a new file in a directory to another directory?only the new/different file [↩](https://www.cyberciti.biz/faq/copy-command/#comment-932628) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-932628 "permalink to this comment") - Ramy Jan 19, 2021 @ 10:37 Im trying to copy a file content , /sbin into another file . it’s working . [↩](https://www.cyberciti.biz/faq/copy-command/#comment-933301) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-933301 "permalink to this comment") - wr19 Mar 23, 2021 @ 13:29 how to copy file from another location like USB to home by command line on terminal? thx before [↩](https://www.cyberciti.biz/faq/copy-command/#comment-933903) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-933903 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [Vivek Gite](https://www.vivekgite.com/) Mar 31, 2021 @ 23:01 Say your USB mounted at /mnt/usb, then: `cp /path/to/file /mnt/usb` [↩](https://www.cyberciti.biz/faq/copy-command/#comment-933962) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-933962 "permalink to this comment") - John McLean May 31, 2021 @ 15:08 You multi-file example says “lib.c” but the command uses “libc.” [↩](https://www.cyberciti.biz/faq/copy-command/#comment-934360) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-934360 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [Vivek Gite](https://www.vivekgite.com/) Aug 21, 2022 @ 5:25 Fixed it. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-943014) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-943014 "permalink to this comment") - Joe Jan 24, 2023 @ 14:08 Nice tutorial. I know you can’t cover everything, but I was wondering if what \`cp -auv …\` will do. I want the archive feature, but I only want to transfer files which have changed. I think that should do it. I turned on v so I can see what it does. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-944185) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-944185 "permalink to this comment") - Anonymous Mar 1, 2023 @ 12:44 Hey, look into rsync command. [↩](https://www.cyberciti.biz/faq/copy-command/#comment-944656) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-944656 "permalink to this comment") - anonymous2x2 Apr 5, 2023 @ 21:54 Is it possible to somehow cp an old-file.txt to a new-file.txt and have the new-file.txt name save in the clipboard for pasting? So that [↩](https://www.cyberciti.biz/faq/copy-command/#comment-944654) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-944654 "permalink to this comment") - 👮🛡️ ![Vivek Gite (Author and Admin)](https://www.cyberciti.biz/media/new/images/vg-nixcraft-author.png) [Vivek Gite](https://www.vivekgite.com/) Apr 6, 2023 @ 4:12 Not possible with the cp command. But you can write a custom bash function or script using xclip-copyfile command. For example: ``` #!/bin/bash input="$1" output="$2" die(){ local m="$*" echo "Error: $0 $m" echo echo "Syntax:" echo "$0 input_file output_file." exit 1 } [ ! -f "$input" ] && die "Input filename missing." echo "Copying file '$input' to '$output' ..." /bin/cp -vi "$input" "$output" \ && echo -e "copy\nfile://${output}\0" \ | xclip -i -selection clipboard -t x-special/gnome-copied-files \ && echo "'$output' file is also copied to Linux clipboard for pasting using the ctrl+v shortcut." ``` Run it as: ``` ./script /path/to/source/input.txt /path/to/dest/out.txt ``` See [How do I copy a file to the clipboard in Linux?](https://www.cyberciti.biz/faq/how-do-i-copy-a-file-to-the-clipboard-in-linux/) [↩](https://www.cyberciti.biz/faq/copy-command/#comment-944655) [∞](https://www.cyberciti.biz/faq/copy-command/#comment-944655 "permalink to this comment") Leave a Reply[Cancel reply](https://www.cyberciti.biz/faq/copy-command/#respond) Use HTML \<pre\>...\</pre\> for code samples. Your comment will appear only after approval by the site admin. Next FAQ: [Linux Creating or Adding New Network Alias To a Network Card (NIC)](https://www.cyberciti.biz/faq/linux-creating-or-adding-new-network-alias-to-a-network-card-nic/) Previous FAQ: [Error /dev/hdX does not have any corresponding BIOS drive and Solution](https://www.cyberciti.biz/faq/error-devhdx-does-not-have-any-corresponding-bios-drive-and-solution/) 🔥 FEATURED ARTICLES - 1 [30 Cool Open Source Software I Discovered in 2013](https://www.cyberciti.biz/open-source/30-cool-best-open-source-softwares-of-2013/) - 2 [30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X](https://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html) - 3 [Top 32 Nmap Command Examples For Linux Sys/Network Admins](https://www.cyberciti.biz/networking/nmap-command-examples-tutorials/) - 4 [25 PHP Security Best Practices For Linux Sys Admins](https://www.cyberciti.biz/tips/php-security-best-practices-tutorial.html) - 5 [30 Linux System Monitoring Tools Every SysAdmin Should Know](https://www.cyberciti.biz/tips/top-linux-monitoring-tools.html) - 6 [40 Linux Server Hardening Security Tips](https://www.cyberciti.biz/tips/linux-security.html) - 7 [Linux: 25 Iptables Netfilter Firewall Examples For New SysAdmins](https://www.cyberciti.biz/tips/linux-iptables-examples.html) - 8 [Top 20 OpenSSH Server Best Security Practices](https://www.cyberciti.biz/tips/linux-unix-bsd-openssh-server-best-practices.html) - 9 [Top 25 Nginx Web Server Best Security Practices](https://www.cyberciti.biz/tips/linux-unix-bsd-nginx-webserver-security.html) - 10 [My 10 UNIX Command Line Mistakes](https://www.cyberciti.biz/tips/my-10-unix-command-line-mistakes.html) 👀 /etc - ➔ [Linux shell scripting tutorial](https://bash.cyberciti.biz/guide/Main_Page "Linux Shell Scripting Tutorial Wiki") - ➔ [RSS/Feed](https://www.cyberciti.com/atom/atom.xml "Get updates using RSS feed") - ➔ [About nixCraft](https://www.cyberciti.biz/tips/about-us "About nixCraft") ©2002-2025 nixCraft • [Privacy](https://www.cyberciti.biz/tips/privacy "Privacy policy") • [ToS](https://www.cyberciti.biz/tips/disclaimer "Term of Service") • [Contact/Email](https://www.cyberciti.biz/tips/contact-us "Contact us via Email") • Corporate patron [Cloudflare](https://www.cyberciti.biz/tips/nixcraft-sponsors "Corporate patron")
Readable Markdownnull
Shard80 (laksa)
Root Hash1965753964674472280
Unparsed URLbiz,cyberciti!www,/faq/copy-command/ s443