🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 53 (from laksa137)

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

đź“„
INDEXABLE
âś…
CRAWLED
16 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.5 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://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file
Last Crawled2026-03-30 02:33:04 (16 days ago)
First Indexed2015-10-01 05:13:08 (10 years ago)
HTTP Status Code200
Meta Titlecommand line - How to copy and paste a file? - Ask Ubuntu
Meta Descriptionnull
Meta Canonicalnull
Boilerpipe Text
You can cut, copy, and paste in CLI intuitively like the way you usually did in the GUI, like so: cd to the folder containing files you want to copy or cut. copy file1 file2 folder1 folder2 or cut file1 folder1 close the current terminal. open another terminal. cd to the folder where you want to paste them. paste To be able to do so, make sure you have installed xclip and realpath . Then, append these functions to the end of your ~/.bashrc file: copy () { # if the number of arguments equals 0 if [ $# -eq 0 ] then # if there are no arguments, save the folder you are currently in to the clipboard pwd | xclip else # save the number of argument/path to `~/.numToCopy` file. echo $# > ~/.numToCopy # save all paths to clipboard # https://stackoverflow.com/q/5265702/9157799#comment128297633_5265775 realpath -s " $@ " | xclip fi # mark that you want to do a copy operation echo "copy" > ~/.copyOrCut } cut () { # use the previous function to save the paths to clipboard copy " $@ " # but mark it as a cut operation echo "cut" > ~/.copyOrCut } paste () { # for every path for ((i= 1 ; i <= $(cat ~/.numToCopy); i++)) do # get the nth path pathToCopy= " $(xclip -o | head -$i | tail -1) " if [ -d " $pathToCopy " ] # If it's a directory then cp -r " $pathToCopy " . else cp " $pathToCopy " . fi # if it was marked as a cut operation if [ $( cat ~/.copyOrCut) = "cut" ] then # delete the original file rm -r " $pathToCopy " fi done } If you don't know what .bashrc file is and never modify it before, just open the file explorer, go to Home, press Ctrl+H (show hidden files), search for .bashrc and open it with a text editor like gedit. Note By using the above script, you are overriding the default functionality of these commands: copy is a reserved PostgreSQL command. cut and paste are reserved Linux command. If you use one of those commands default functionality, just modify the script function names accordingly. For example, use p instead of paste .
Markdown
# ![site logo](https://stackoverflow.com/Content/Img/SE-logo75.png) By clicking “Sign up”, you agree to our [terms of service](https://askubuntu.com/legal/terms-of-service/public) and acknowledge you have read our [privacy policy](https://askubuntu.com/legal/privacy-policy). # OR Already have an account? [Log in](https://askubuntu.com/users/login) - [Ubuntu](http://www.ubuntu.com/) - [Community](http://community.ubuntu.com/) - [Ask\!](http://askubuntu.com/) - [Developer](http://developer.ubuntu.com/) - [Design](http://design.ubuntu.com/) - [Hardware](http://www.ubuntu.com/certification) - [Insights](http://insights.ubuntu.com/) - [Juju](https://jujucharms.com/) - [Shop](http://shop.ubuntu.com/) - [More ›](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file) - [Apps](http://apps.ubuntu.com/) - [Help](https://help.ubuntu.com/) - [Forum](http://ubuntuforums.org/) - [Launchpad](http://www.launchpad.net/) - [MAAS](http://maas.ubuntu.com/) - [Canonical](http://www.canonical.com/) [Skip to main content](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file#content) #### Stack Exchange Network Stack Exchange network consists of 183 Q\&A communities including [Stack Overflow](https://stackoverflow.com/), the largest, most trusted online community for developers to learn, share their knowledge, and build their careers. [Visit Stack Exchange](https://stackexchange.com/) 1. - [Tour Start here for a quick overview of the site](https://askubuntu.com/tour) - [Help Center Detailed answers to any questions you might have](https://askubuntu.com/help) - [Meta Discuss the workings and policies of this site](https://meta.askubuntu.com/) - [About Us Learn more about Stack Overflow the company, and our products](https://stackoverflow.co/) 2. ### [current community](https://askubuntu.com/) - [Ask Ubuntu](https://askubuntu.com/) [help](https://askubuntu.com/help) [chat](https://chat.stackexchange.com/?tab=site&host=askubuntu.com) - [Ask Ubuntu Meta](https://meta.askubuntu.com/) ### your communities [Sign up](https://askubuntu.com/users/signup?ssrc=site_switcher&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F400152%2Fhow-to-copy-and-paste-a-file) or [log in](https://askubuntu.com/users/login?ssrc=site_switcher&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F400152%2Fhow-to-copy-and-paste-a-file) to customize your list. ### [more stack exchange communities](https://stackexchange.com/sites) [company blog](https://stackoverflow.blog/) 3. [Log in](https://askubuntu.com/users/login?ssrc=head&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F400152%2Fhow-to-copy-and-paste-a-file) 4. [Sign up](https://askubuntu.com/users/signup?ssrc=head&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F400152%2Fhow-to-copy-and-paste-a-file) [![Ask Ubuntu](https://askubuntu.com/Content/Sites/askubuntu/Img/logo.svg?v=472cf2768bba)](https://askubuntu.com/) 1. 1. [Home](https://askubuntu.com/) 2. [Questions](https://askubuntu.com/questions) 3. [Unanswered](https://askubuntu.com/unanswered) 4. [AI Assist](https://stackoverflow.com/ai-assist) 5. [Tags](https://askubuntu.com/tags) 6. [Chat](https://chat.stackexchange.com/) 7. [Users](https://askubuntu.com/users) 8. [Companies](https://stackoverflow.com/jobs/companies?so_medium=askubuntu&so_source=SiteNav) 2. Stack Internal Stack Overflow for Teams is now called **Stack Internal**. Bring the best of human thought and AI automation together at your work. [Try for free](https://stackoverflowteams.com/teams/create/free/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams) [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams) 3. [Stack Internal]() 4. Bring the best of human thought and AI automation together at your work. [Learn more](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams-compact) **Stack Internal** Knowledge at work Bring the best of human thought and AI automation together at your work. [Explore Stack Internal](https://stackoverflow.co/internal/?utm_medium=referral&utm_source=askubuntu-community&utm_campaign=side-bar&utm_content=explore-teams-compact-popover) # [How to copy and paste a file?](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file) [Ask Question](https://askubuntu.com/questions/ask) Asked 12 years, 2 months ago Modified [2 years, 8 months ago](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file?lastactivity "2023-07-08 05:23:50Z") Viewed 386k times This question shows research effort; it is useful and clear 33 Save this question. Show activity on this post. I want copy and paste a file. The name of the file is `mkoctfile.m`. The path of this file is: `/usr/share/octave/3.2.4/m/miscellaneous/mkoctfile.m` I want to paste it to the following path `/usr/bin/mkoctfile-3.2.4` I have made the directory by using following commands: `sudo su` `mkdir -p /usr/bin/mkoctfile-3.2.4` but I don't know how to copy and paste `mkoctfile.m` in this path. Please tell me what command I have to use. - [command-line](https://askubuntu.com/questions/tagged/command-line "show questions tagged 'command-line'") - [gnome-terminal](https://askubuntu.com/questions/tagged/gnome-terminal "show questions tagged 'gnome-terminal'") [Share](https://askubuntu.com/q/400152 "Short permalink to this question") Share a link to this question Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this question](https://askubuntu.com/posts/400152/edit) Follow Follow this question to receive notifications [edited Aug 23, 2019 at 7:02](https://askubuntu.com/posts/400152/revisions "show all edits to this post") [![RolandiXor's user avatar](https://www.gravatar.com/avatar/d629b6ac45d58dbd918c0246b364748d?s=64&d=identicon&r=PG)](https://askubuntu.com/users/1992/rolandixor) [RolandiXor](https://askubuntu.com/users/1992/rolandixor) 52\.1k3434 gold badges176176 silver badges267267 bronze badges asked Jan 4, 2014 at 19:46 [![osama's user avatar](https://graph.facebook.com/100002203669599/picture?type=large)](https://askubuntu.com/users/228710/osama) [osama](https://askubuntu.com/users/228710/osama) 1,11144 gold badges1414 silver badges1919 bronze badges [Add a comment](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file "Use comments to ask for more information or suggest improvements. Avoid answering questions in comments.") \| ## 4 Answers 4 Sorted by: [Reset to default](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file?answertab=scoredesc#tab-top) This answer is useful 58 Save this answer. Show activity on this post. Use the `cp` command to copy a file, the syntax goes `cp sourcefile destinationfile`. Use the `mv` command to move the file, basically cut and paste it somewhere else. The exact syntax you would use for your example is: ``` sudo cp /usr/bin/octave/3.2.4/m/miscellaneous/mkoctfile.m /usr/bin/mkoctfile-3.2.4 ``` For more information on the `cp` or `mv` commands you can run: ``` man cp ``` or ``` man mv ``` To view the manual pages [Share](https://askubuntu.com/a/400156 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 3.0](https://creativecommons.org/licenses/by-sa/3.0/ "The current license for this post: CC BY-SA 3.0") [Improve this answer](https://askubuntu.com/posts/400156/edit) Follow Follow this answer to receive notifications [edited Jan 4, 2014 at 20:31](https://askubuntu.com/posts/400156/revisions "show all edits to this post") [![Julian Stirling's user avatar](https://i.sstatic.net/mkilb.jpg?s=64)](https://askubuntu.com/users/139634/julian-stirling) [Julian Stirling](https://askubuntu.com/users/139634/julian-stirling) 2,9292121 silver badges2929 bronze badges answered Jan 4, 2014 at 20:03 [![steve51516's user avatar](https://www.gravatar.com/avatar/d297c8e24f157bb2a38119676d059829?s=64&d=identicon&r=PG)](https://askubuntu.com/users/169254/steve51516) [steve51516](https://askubuntu.com/users/169254/steve51516) 1,17611 gold badge1010 silver badges66 bronze badges 3 - 1 thanks! but typing out the full file path is difficult. is there a better way? BenKoshy – [BenKoshy](https://askubuntu.com/users/453324/benkoshy "131 reputation") 2016-01-19 23:16:58 +00:00 [Commented Jan 19, 2016 at 23:16](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file#comment1069636_400156) - 1 To @BKSurgeon, I would suggest to use the tab key to see the paths/directories available, or type ls to see them all at once printed. Jumanazar Said – [Jumanazar Said](https://askubuntu.com/users/987883/jumanazar-said "1 reputation") 2019-08-23 02:41:09 +00:00 [Commented Aug 23, 2019 at 2:41](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file#comment1948022_400156) - I think it is better to use `cp -a` than just `cp`, if you want to have the same affect as when copy-pasting in desktop GUI. Alexey – [Alexey](https://askubuntu.com/users/448153/alexey "803 reputation") 2020-12-14 07:48:52 +00:00 [Commented Dec 14, 2020 at 7:48](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file#comment2209497_400156) [Add a comment](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| This answer is useful 3 Save this answer. Show activity on this post. You can cut, copy, and paste in CLI intuitively like the way you usually did in the GUI, like so: - `cd` to the folder containing files you want to copy or cut. - `copy file1 file2 folder1 folder2` or `cut file1 folder1` - close the current terminal. - open another terminal. - `cd` to the folder where you want to paste them. - `paste` To be able to do so, make sure you have installed `xclip` and `realpath`. Then, append these functions to the end of your *~/.bashrc* file: ``` copy() { # if the number of arguments equals 0 if [ $# -eq 0 ] then # if there are no arguments, save the folder you are currently in to the clipboard pwd | xclip else # save the number of argument/path to `~/.numToCopy` file. echo $# > ~/.numToCopy # save all paths to clipboard # https://stackoverflow.com/q/5265702/9157799#comment128297633_5265775 realpath -s "$@" | xclip fi # mark that you want to do a copy operation echo "copy" > ~/.copyOrCut } cut() { # use the previous function to save the paths to clipboard copy "$@" # but mark it as a cut operation echo "cut" > ~/.copyOrCut } paste() { # for every path for ((i=1; i <= $(cat ~/.numToCopy); i++)) do # get the nth path pathToCopy="$(xclip -o | head -$i | tail -1)" if [ -d "$pathToCopy" ] # If it's a directory then cp -r "$pathToCopy" . else cp "$pathToCopy" . fi # if it was marked as a cut operation if [ $(cat ~/.copyOrCut) = "cut" ] then # delete the original file rm -r "$pathToCopy" fi done } ``` If you don't know what *.bashrc* file is and never modify it before, just open the file explorer, go to Home, press Ctrl+H (show hidden files), search for *.bashrc* and open it with a text editor like gedit. **Note** By using the above script, you are overriding the default functionality of these commands: - `copy` is a reserved PostgreSQL command. - `cut` and `paste` are reserved Linux command. If you use one of those commands default functionality, just modify the script function names accordingly. For example, use `p` instead of `paste`. [Share](https://askubuntu.com/a/1317394 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://askubuntu.com/posts/1317394/edit) Follow Follow this answer to receive notifications [edited Jun 15, 2022 at 12:25](https://askubuntu.com/posts/1317394/revisions "show all edits to this post") answered Feb 18, 2021 at 11:52 [![M Imam Pratama's user avatar](https://i.sstatic.net/zOl1wO5n.jpg?s=64)](https://askubuntu.com/users/356625/m-imam-pratama) [M Imam Pratama](https://askubuntu.com/users/356625/m-imam-pratama) 24422 silver badges1313 bronze badges [Add a comment](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| This answer is useful 0 Save this answer. Show activity on this post. Go to that directory from where you want to copy file i.e /usr/bin/octave/3.2.4/m/miscellaneous ``` cd /usr/bin/octave/3.2.4/m/miscellaneous ``` Then type ``` `cp mkoctfile.m ../../../mkoctfile-3.2.4` ``` `../../../` means you are going backward to bin folder and type whatever directory in which you want to copy your file. [Share](https://askubuntu.com/a/1160908 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://askubuntu.com/posts/1160908/edit) Follow Follow this answer to receive notifications answered Jul 25, 2019 at 7:17 [![MD Rijwan's user avatar](https://graph.facebook.com/1775466446001936/picture?type=large)](https://askubuntu.com/users/978687/md-rijwan) [MD Rijwan](https://askubuntu.com/users/978687/md-rijwan) 10111 bronze badge [Add a comment](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| This answer is useful 0 Save this answer. Show activity on this post. An interesting solution based on @M Imam Pratama's idea (Copy / Cut now and paste later). Consider using [xclip-copyfile, xclip-cutfile and xclip-pastefile](https://manpages.ubuntu.com/manpages/lunar/en/man1/xclip-copyfile.1.html). ``` $ xclip-copyfile file1 $ xclip-cutfile file1 $ xclip-pastefile file1 ``` You can also copy an entire tree structure. **WARNING:** `xclip-cutfile` immediately remove the file, does not wait until you paste it. [Share](https://askubuntu.com/a/1476994 "Short permalink to this answer") Share a link to this answer Copy link [CC BY-SA 4.0](https://creativecommons.org/licenses/by-sa/4.0/ "The current license for this post: CC BY-SA 4.0") [Improve this answer](https://askubuntu.com/posts/1476994/edit) Follow Follow this answer to receive notifications [edited Jul 8, 2023 at 5:23](https://askubuntu.com/posts/1476994/revisions "show all edits to this post") answered Jul 8, 2023 at 5:17 [![Ahmad Ismail's user avatar](https://www.gravatar.com/avatar/f768b6e41490b85bcfa9823404519fa8?s=64&d=identicon&r=PG&f=y&so-version=2)](https://askubuntu.com/users/598062/ahmad-ismail) [Ahmad Ismail](https://askubuntu.com/users/598062/ahmad-ismail) 8181212 silver badges3232 bronze badges [Add a comment](https://askubuntu.com/questions/400152/how-to-copy-and-paste-a-file "Use comments to ask for more information or suggest improvements. Avoid comments like “+1” or “thanks”.") \| ## You must [log in](https://askubuntu.com/users/login?ssrc=question_page&returnurl=https%3A%2F%2Faskubuntu.com%2Fquestions%2F400152) to answer this question. **[Protected question](https://askubuntu.com/help/privileges/protect-questions)**. To answer this question, you need to have at least 10 reputation on this site (not counting the [association bonus](https://meta.stackexchange.com/questions/141648/what-is-the-association-bonus-and-how-does-it-work)). The reputation requirement helps protect this question from spam and non-answer activity. Start asking to get answers Find the answer to your question by asking. [Ask question](https://askubuntu.com/questions/ask) Explore related questions - [command-line](https://askubuntu.com/questions/tagged/command-line "show questions tagged 'command-line'") - [gnome-terminal](https://askubuntu.com/questions/tagged/gnome-terminal "show questions tagged 'gnome-terminal'") See similar questions with these tags. - The Overflow Blog - [Prevent agentic identity theft](https://stackoverflow.blog/2026/03/27/prevent-agentic-identity-theft/?cb=1) - [Building shared coding guidelines for AI (and people too)](https://stackoverflow.blog/2026/03/26/coding-guidelines-for-ai-agents-and-people-too/?cb=1) - Featured on Meta - [Should the Community Bot stop bumping questions from EOL releases?](https://meta.askubuntu.com/questions/20776/should-the-community-bot-stop-bumping-questions-from-eol-releases?cb=1) #### Related [2](https://askubuntu.com/questions/44807/copy-paste-a-file-utility-for-terminal?rq=1 "Question score (upvotes - downvotes)") [Copy & Paste a file utility for terminal](https://askubuntu.com/questions/44807/copy-paste-a-file-utility-for-terminal?rq=1) [4](https://askubuntu.com/questions/627009/how-to-add-flags-and-or-arguments-to-a-command-in-the-sudoers-file?rq=1 "Question score (upvotes - downvotes)") [How to add flags and/or arguments to a command in the 'sudoers' file](https://askubuntu.com/questions/627009/how-to-add-flags-and-or-arguments-to-a-command-in-the-sudoers-file?rq=1) [4](https://askubuntu.com/questions/861690/copy-specific-text-from-a-multiple-line-file-and-paste-it-in-another-file-automa?rq=1 "Question score (upvotes - downvotes)") [Copy specific text from a multiple line file and paste it in another file automatically using terminal](https://askubuntu.com/questions/861690/copy-specific-text-from-a-multiple-line-file-and-paste-it-in-another-file-automa?rq=1) [2](https://askubuntu.com/questions/911708/copy-file-via-terminal-with-wildcard-in-command-like-cp-path-dat-dist-path?rq=1 "Question score (upvotes - downvotes)") [Copy file via terminal with wildcard in command like cp /path/\*.dat /dist/path/](https://askubuntu.com/questions/911708/copy-file-via-terminal-with-wildcard-in-command-like-cp-path-dat-dist-path?rq=1) [2](https://askubuntu.com/questions/939655/lock-copy-paste-input-to-terminal-while-sudo-prompts-for-password?rq=1 "Question score (upvotes - downvotes)") [Lock copy-paste input to terminal while sudo prompts for password](https://askubuntu.com/questions/939655/lock-copy-paste-input-to-terminal-while-sudo-prompts-for-password?rq=1) [4](https://askubuntu.com/questions/970927/copy-paste-loop-code?rq=1 "Question score (upvotes - downvotes)") [Copy/Paste loop code](https://askubuntu.com/questions/970927/copy-paste-loop-code?rq=1) [0](https://askubuntu.com/questions/1191048/i-want-to-copy-my-present-working-directory-location-into-abc-text-file-by-repla?rq=1 "Question score (upvotes - downvotes)") [I want to copy my present working directory location into abc.text file by replacing some sentence](https://askubuntu.com/questions/1191048/i-want-to-copy-my-present-working-directory-location-into-abc-text-file-by-repla?rq=1) #### [Hot Network Questions](https://stackexchange.com/questions?tab=hot) - [Trying to remember the name of a movie where a very powerful AI needs to be defeated and one of the main characters ask it what time it is](https://scifi.stackexchange.com/questions/303847/trying-to-remember-the-name-of-a-movie-where-a-very-powerful-ai-needs-to-be-defe) - [Midrash source for "there are factors that cause a man to age"](https://judaism.stackexchange.com/questions/155634/midrash-source-for-there-are-factors-that-cause-a-man-to-age) - [tabular text besides image](https://tex.stackexchange.com/questions/761303/tabular-text-besides-image) - [Why was Cameron able to destroy Cromartie with a shotgun?](https://scifi.stackexchange.com/questions/303853/why-was-cameron-able-to-destroy-cromartie-with-a-shotgun) - [A political campaign texted me after I sent them a STOP message, does this violate the Telephone Consumer Protection Act?](https://law.stackexchange.com/questions/114473/a-political-campaign-texted-me-after-i-sent-them-a-stop-message-does-this-viola) - [How long will it take the remaining cleaners?](https://math.stackexchange.com/questions/5130333/how-long-will-it-take-the-remaining-cleaners) - [Difference between molecular geometry and shape in VSEPR](https://chemistry.stackexchange.com/questions/195292/difference-between-molecular-geometry-and-shape-in-vsepr) - [Draw a TikZ path behind cell content and rules in nicematrix](https://tex.stackexchange.com/questions/761375/draw-a-tikz-path-behind-cell-content-and-rules-in-nicematrix) - [41 years of confusing Windows version naming](https://codegolf.stackexchange.com/questions/287682/41-years-of-confusing-windows-version-naming) - [All curves after the first lose their transparency after export to PDF](https://mathematica.stackexchange.com/questions/319110/all-curves-after-the-first-lose-their-transparency-after-export-to-pdf) - [PostgreSQL prepared statement becomes slower after repeated executions because the optimal plan changes](https://stackoverflow.com/questions/79915779/postgresql-prepared-statement-becomes-slower-after-repeated-executions-because-t) - [Format a LibreOffice Calc cell to display an improper ("top-heavy") fraction](https://superuser.com/questions/1936259/format-a-libreoffice-calc-cell-to-display-an-improper-top-heavy-fraction) - [Power analysis for determining what amount of time to analyze data](https://stats.stackexchange.com/questions/675374/power-analysis-for-determining-what-amount-of-time-to-analyze-data) - [Singularity Problem with gls that isn't present in lm](https://stats.stackexchange.com/questions/675359/singularity-problem-with-gls-that-isnt-present-in-lm) - [Speed of light as limit of information or limit of energy transfer](https://physics.stackexchange.com/questions/870632/speed-of-light-as-limit-of-information-or-limit-of-energy-transfer) - [Finding a lecture by David Gillman on “The best picture of Poincaré homology sphere”](https://math.stackexchange.com/questions/5130734/finding-a-lecture-by-david-gillman-on-the-best-picture-of-poincar%C3%A9-homology-sph) - [The Meaning of Forgiveness in Christianity](https://christianity.stackexchange.com/questions/113454/the-meaning-of-forgiveness-in-christianity) - [Parallels in sequences?](https://music.stackexchange.com/questions/143417/parallels-in-sequences) - [Lattice-based oblivious transfer](https://crypto.stackexchange.com/questions/119478/lattice-based-oblivious-transfer) - [Ignoring the tail of the letter "g" in setting the baseline of text in nodes of a tikz diagram](https://tex.stackexchange.com/questions/761310/ignoring-the-tail-of-the-letter-g-in-setting-the-baseline-of-text-in-nodes-of) - [Generate a large number using + and ×](https://codegolf.stackexchange.com/questions/287678/generate-a-large-number-using-and-%C3%97) - [If \*wh-movement\* is blocked by a syntactic island, how can we form an interrogative clause?](https://english.stackexchange.com/questions/639324/if-wh-movement-is-blocked-by-a-syntactic-island-how-can-we-form-an-interrogat) - [Beamer miniframes: side-by-side gets shifted when \\beamergotobutton](https://tex.stackexchange.com/questions/761381/beamer-miniframes-side-by-side-gets-shifted-when-beamergotobutton) - [4x4 grid with all 7 adjacent colour pairs](https://puzzling.stackexchange.com/questions/137529/4x4-grid-with-all-7-adjacent-colour-pairs) [Question feed](https://askubuntu.com/feeds/question/400152 "Feed of this question and its answers") # Subscribe to RSS Question feed To subscribe to this RSS feed, copy and paste this URL into your RSS reader. ![](https://askubuntu.com/posts/400152/ivc/70ea?prg=60a482b3-4fed-40a3-8d04-a3086b9c2450) # Why are you flagging this comment? It contains harassment, bigotry or abuse. This comment attacks a person or group. Learn more in our [Abusive behavior policy](https://askubuntu.com/conduct/abusive-behavior). It's unfriendly or unkind. This comment is rude or condescending. Learn more in our [Code of Conduct](https://askubuntu.com/conduct/abusive-behavior). Not needed. This comment is not relevant to the post. ``` ``` Enter at least 6 characters Something else. A problem not listed above. Try to be as specific as possible. ``` ``` Enter at least 6 characters Flag comment Cancel You have 0 flags left today # ![Illustration of upvote icon after it is clicked](https://askubuntu.com/Content/Img/modal/img-upvote.png?v=fce73bd9724d) # Hang on, you can't upvote just yet. You'll need to complete a few actions and gain 15 reputation points before being able to upvote. **Upvoting** indicates when questions and answers are useful. [What's reputation and how do I get it?](https://stackoverflow.com/help/whats-reputation) Instead, you can save this post to reference later. Save this post for later Not now ##### [Ask Ubuntu](https://askubuntu.com/) - [Tour](https://askubuntu.com/tour) - [Help](https://askubuntu.com/help) - [Chat](https://chat.stackexchange.com/?tab=site&host=askubuntu.com) - [Contact](https://askubuntu.com/contact) - [Feedback](https://meta.askubuntu.com/) ##### [Company](https://stackoverflow.co/) - [Stack Overflow](https://stackoverflow.com/) - [Stack Internal](https://stackoverflow.co/internal/) - [Stack Data Licensing](https://stackoverflow.co/data-licensing/) - [Stack Ads](https://stackoverflow.co/advertising/) - [About](https://stackoverflow.co/) - [Press](https://stackoverflow.co/company/press/) - [Legal](https://stackoverflow.com/legal) - [Privacy Policy](https://stackoverflow.com/legal/privacy-policy) - [Terms of Service](https://stackoverflow.com/legal/terms-of-service/public) - Cookie Settings - [Cookie Policy](https://policies.stackoverflow.co/stack-overflow/cookie-policy) ##### [Stack Exchange Network](https://stackexchange.com/) - [Technology](https://stackexchange.com/sites#technology) - [Culture & recreation](https://stackexchange.com/sites#culturerecreation) - [Life & arts](https://stackexchange.com/sites#lifearts) - [Science](https://stackexchange.com/sites#science) - [Professional](https://stackexchange.com/sites#professional) - [Business](https://stackexchange.com/sites#business) - [API](https://api.stackexchange.com/) - [Data](https://data.stackexchange.com/) - [Blog](https://stackoverflow.blog/?blb=1) - [Facebook](https://www.facebook.com/officialstackoverflow/) - [Twitter](https://twitter.com/stackoverflow) - [LinkedIn](https://linkedin.com/company/stack-overflow) - [Instagram](https://www.instagram.com/thestackoverflow) Site design / logo © 2026 Stack Exchange Inc; user contributions licensed under [CC BY-SA](https://stackoverflow.com/help/licensing) . rev 2026.3.27.41560 Ubuntu and the circle of friends logo are trade marks of Canonical Limited and are used under licence.
Readable Markdown
You can cut, copy, and paste in CLI intuitively like the way you usually did in the GUI, like so: - `cd` to the folder containing files you want to copy or cut. - `copy file1 file2 folder1 folder2` or `cut file1 folder1` - close the current terminal. - open another terminal. - `cd` to the folder where you want to paste them. - `paste` To be able to do so, make sure you have installed `xclip` and `realpath`. Then, append these functions to the end of your *~/.bashrc* file: ``` copy() { # if the number of arguments equals 0 if [ $# -eq 0 ] then # if there are no arguments, save the folder you are currently in to the clipboard pwd | xclip else # save the number of argument/path to `~/.numToCopy` file. echo $# > ~/.numToCopy # save all paths to clipboard # https://stackoverflow.com/q/5265702/9157799#comment128297633_5265775 realpath -s "$@" | xclip fi # mark that you want to do a copy operation echo "copy" > ~/.copyOrCut } cut() { # use the previous function to save the paths to clipboard copy "$@" # but mark it as a cut operation echo "cut" > ~/.copyOrCut } paste() { # for every path for ((i=1; i <= $(cat ~/.numToCopy); i++)) do # get the nth path pathToCopy="$(xclip -o | head -$i | tail -1)" if [ -d "$pathToCopy" ] # If it's a directory then cp -r "$pathToCopy" . else cp "$pathToCopy" . fi # if it was marked as a cut operation if [ $(cat ~/.copyOrCut) = "cut" ] then # delete the original file rm -r "$pathToCopy" fi done } ``` If you don't know what *.bashrc* file is and never modify it before, just open the file explorer, go to Home, press Ctrl+H (show hidden files), search for *.bashrc* and open it with a text editor like gedit. **Note** By using the above script, you are overriding the default functionality of these commands: - `copy` is a reserved PostgreSQL command. - `cut` and `paste` are reserved Linux command. If you use one of those commands default functionality, just modify the script function names accordingly. For example, use `p` instead of `paste`.
Shard53 (laksa)
Root Hash9277990770814737653
Unparsed URLcom,askubuntu!/questions/400152/how-to-copy-and-paste-a-file s443