mkdir, cp, mv, rm, touch - oregon state...

Post on 02-Feb-2018

215 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

mkdir, cp, mv, rm, touch

‣ Create a single directory –  UNIX> mkdir newDirectoryName

‣ Create multiple directories at once –  UNIX> mkdir dir1 dir2 dir3

‣ Create directory within an existing directory –  UNIX> mkdir dir1/dir1a

‣ Syntax: –  UNIX> cp source destination

‣ Use –r option for directories –  UNIX> cp –r dir1 dir1_copy

‣ Be careful! –  There is NO UNDO

–  You can easily overwrite files

–  UNIX> cp not_so_important.txt crucial.txt

‣ Syntax: –  UNIX> mv source destination

‣ Examples: –  Move file1.txt to the above directory: ‧  UNIX> mv file1.txt ../

–  Rename file1.txt to new_name.txt ‧  UNIX> mv file.txt new_name.txt

‣ Delete single file: –  UNIX> rm file

‣ Delete multiple files at once: –  UNIX> rm file1 file2 file3

‣ Delete a directory (recursive) –  UNIX> rm –r dir1

‣  ***BE VERY CAREFUL WITH rm –r*** –  NO UNDO!!!

–  Why is rm –r / the most evil command ever?

‣ Syntax: –  UNIX> touch fileName [file2] [file3] […]

‣ Create a new blank file –  UNIX> touch newBlankFile.txt

‣ Update the file’s timestamp –  UNIX> touch newBlankFile.txt

‣ Update several files at once: –  UNIX> touch file1.txt newBlankFile.txt file2.txt

‣ With great power comes great responsibility…

h#p://www.youtube.com/watch?v=D4fzInlyYQo  

‣ http://eecs.mines.edu/Courses/csci274/Assignments/3_file_commands.html

top related