Clipboard for copying and pasting files in command line?

Tim

In Bash, suppose I visit a directory, and then another directory. I would like to copy a file from the first directory to the second directory, but without specifying the long pathnames of them. Is it possible?

My temporary solution is to use /tmp as a temporary place to store a copy of the file. cp myfile /tmp when I am in the first directory, and then cp /tmp/myfile . when I am in the second directory. But I may check if the file will overwrite anything in /tmp.

Is there something similar to a clipboard for copying and pasting a file?

Anderson Medeiros Gomes

Using Bash, I would just visit the directories:

$ cd /path/to/source/directory
$ cd /path/to/destination/directory

Then, I would use the shortcut ~-, which points to the previous directory:

$ cp -v ~-/file1.txt .
$ cp -v ~-/file2.txt .
$ cp -v ~-/file3.txt .

If one wants to visit directories in reverse order, then:

$ cp -v fileA.txt ~-
$ cp -v fileB.txt ~-
$ cp -v fileC.txt ~-

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Copying files from command line to clipboard

From Dev

Copying files from command line to clipboard

From Dev

Copying files to clipboard and then pasting them into their original folder does not work

From Dev

What is the command line equivalent of copying a file to clipboard?

From Dev

Copying and Pasting Files with VBScript

From Dev

Is it possible to type μ on the bash command line without copying and pasting?

From Dev

copying last bash command into clipboard

From Dev

Create custom Xterm keybindings for copying, pasting using the clipboard

From Dev

Opening .XLSX files and copying/pasting data

From Dev

Command Line Clipboard Access

From Dev

copying and pasting Unicode characters (specifically hebrew) from clipboard using win32clipboard

From Dev

Copying WindowsImageBackup in command line

From Dev

Python Canopy NumPy: Running the code by pressing "Play" doesn't give the same result as copying and pasting the code in the command line

From Dev

Copying to the clipboard in PowerShell without a new line

From Dev

Copying and pasting logarithmic trend line equation from chart into cell

From Dev

VBA - Copying and Pasting from Multiple Excel files to Single Excel File

From Dev

VBA - Copying and Pasting from Multiple Excel files to Single Excel File

From Dev

Clipboard manager(s) not pasting

From Dev

How can I prevent javascript from copying a line break to clipboard?

From Dev

Copying & Pasting with URxvt

From Dev

A command-line clipboard copy and paste utility?

From Dev

A command-line clipboard copy and paste utility?

From Dev

Operate X clipboard from command line

From Dev

How to pipe text from command line to the clipboard

From Dev

Using command line to copy html file to clipboard

From Dev

Error copying directories at command line using cp

From Dev

Copying file path from GUI to the command line

From Dev

Pasting many files together in some sort of loop, paste command

From Dev

Copying multiple types of files in one command

Related Related

  1. 1

    Copying files from command line to clipboard

  2. 2

    Copying files from command line to clipboard

  3. 3

    Copying files to clipboard and then pasting them into their original folder does not work

  4. 4

    What is the command line equivalent of copying a file to clipboard?

  5. 5

    Copying and Pasting Files with VBScript

  6. 6

    Is it possible to type μ on the bash command line without copying and pasting?

  7. 7

    copying last bash command into clipboard

  8. 8

    Create custom Xterm keybindings for copying, pasting using the clipboard

  9. 9

    Opening .XLSX files and copying/pasting data

  10. 10

    Command Line Clipboard Access

  11. 11

    copying and pasting Unicode characters (specifically hebrew) from clipboard using win32clipboard

  12. 12

    Copying WindowsImageBackup in command line

  13. 13

    Python Canopy NumPy: Running the code by pressing "Play" doesn't give the same result as copying and pasting the code in the command line

  14. 14

    Copying to the clipboard in PowerShell without a new line

  15. 15

    Copying and pasting logarithmic trend line equation from chart into cell

  16. 16

    VBA - Copying and Pasting from Multiple Excel files to Single Excel File

  17. 17

    VBA - Copying and Pasting from Multiple Excel files to Single Excel File

  18. 18

    Clipboard manager(s) not pasting

  19. 19

    How can I prevent javascript from copying a line break to clipboard?

  20. 20

    Copying & Pasting with URxvt

  21. 21

    A command-line clipboard copy and paste utility?

  22. 22

    A command-line clipboard copy and paste utility?

  23. 23

    Operate X clipboard from command line

  24. 24

    How to pipe text from command line to the clipboard

  25. 25

    Using command line to copy html file to clipboard

  26. 26

    Error copying directories at command line using cp

  27. 27

    Copying file path from GUI to the command line

  28. 28

    Pasting many files together in some sort of loop, paste command

  29. 29

    Copying multiple types of files in one command

HotTag

Archive