shelllings

a practical way to learn shell
Log | Files | Refs | README | LICENSE

13_copying_and_moving.sh (959B)


      1 #!/bin/sh
      2 
      3 # You can copy files and move them from one location to another. When
      4 # you "move" a file, you are changing its location. When you copy a
      5 # file, within the same filesystem, this is just renaming the file path.
      6 # When you copy a file, you create a new, separate copy of the file's
      7 # contents in another location.
      8 #
      9 # $ cp file1 file2          # this copies the contents, permissions,
     10 #                             and metadata
     11 # $ cp file dir/            # copies the file into a directory
     12 #
     13 # $ mv file /to/new/path/   # moves the file to a new location
     14 # $ mv old_name new_name
     15 #
     16 # Often if you really don't want the metadata, and just want to have
     17 # the contents copied, you can use the cat command
     18 #
     19 # $ cat file_withmetadata > new_file
     20 #
     21 # Fix this program that is built off from the previous exercise by
     22 # having the file be renamed into a file named 11_user_input
     23 printf "Enter your sentence: "
     24 read user_input
     25 echo "$user_input" > 11_file
     26