24

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.

41

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

  • 1
    thanks! but typing out the full file path is difficult. is there a better way? – BKSpurgeon Jan 19 '16 at 23:16
  • 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. – Jimmy Aug 23 at 2:41
0

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.