10

I am trying to copy a file using Julia functions with the hope of manipulating the file and then use that copied version for various tasks in the Julia programming language. Can someone provide some example code of copying a file in Julia?

I guess I could do use read then write but it seems like I would be reinventing the wheel. Is there a standard library function for this?

Inspired by this question.

Frames Catherine White
  • 27,368
  • 21
  • 87
  • 137
logankilpatrick
  • 13,148
  • 7
  • 44
  • 125

1 Answers1

15

Just use the built in function cp(src, dst).

Copy the file, link, or directory from src to dst. force=true will first remove an existing dst.

Afterwards you can open the file and manipulate it. Of course you could also open both source an destination files simultaneously and copy and manipulate it line by line.

carstenbauer
  • 9,817
  • 1
  • 27
  • 40