13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

12Chapter 1An Embarrassment of Riches: The <strong>Linux</strong> Envir<strong>on</strong>ment1.3.5 File CopyingDo you know these commands?• mv• cp• lnThe mv command (short for “move”) lets you move a file from <strong>on</strong>e placein the hierarchy of files to another—that is, from <strong>on</strong>e directory to another.When you move the file, you can give it a new name. If you move it withoutputting it in a different directory, well, that’s just renaming the file.• mv Classy.java Nouveau.java• mv Classy.java /tmp/outamy.way• mv Classx.java Classz.java ..• mv /usr/oldproject/*.java .The first example moves Classy.java to a new name, Nouveau.java,while leaving the file in the same directory.The sec<strong>on</strong>d example moves the file named Classy.java from the currentdirectory over to the /tmp directory and renames it outamy.way—unless thefile outamy.way is an already existing directory. In that case, the fileClassy.java will end up (still named Classy.java) inside the directoryoutamy.way.The next example just moves the two Java source files up <strong>on</strong>e level, to theparent directory. The “..” is a feature of every <strong>Linux</strong> directory. Whenever youcreate a directory, it gets created with two links already built in: “..” points toits parent (the directory that c<strong>on</strong>tains it), and “.” points to the directory itself.A comm<strong>on</strong> questi<strong>on</strong> at this point is, “Why does a directory need a referenceto itself?” Whatever other reas<strong>on</strong>s there may be, it certainly is a handyshorthand to refer to the current directory. If you need to move a whole lot offiles from <strong>on</strong>e directory to another, you can use the “.” as your destinati<strong>on</strong>.That’s the fourth example.The cp command is much like the mv command, but the original file isleft right where it is. In other words, it copies files instead of moving them. So:cp Classy.java Nouveau.java

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!