UNIX Copying Multiple Files to a Sibling Directory From inside the programs directory, which command copies the three files wb, collect, and mon into the sibling directory ../misc while keeping their names?

Computer Science Unix Difficulty: Easy
Choose an option
  • A
    copy wb ../misc collect ../misc mon ../misc
  • B
    cp wb collect mon ../misc
  • C
    copy wb collect mon /misc
  • D
    tar wb collect mon /misc
  • E
    None of the above

Answer

Correct Answer: cp wb collect mon ../misc

Explanation

Introduction / Context:On UNIX-like systems, copying multiple files into a target directory is accomplished using the cp command. Understanding relative paths (such as ../misc) helps navigate and manage files efficiently across sibling directories.

Given Data / Assumptions:

  • You are currently in the programs directory.
  • There exists a sibling directory misc one level up: ../misc.
  • Files wb, collect, and mon reside in the current directory.

Concept / Approach:Use cp followed by a list of source files and the destination directory. A relative path beginning with ../ refers to the parent directory; appending misc targets the sibling directory named misc.

Step-by-Step Solution:Confirm current directory with pwd and listing with ls.Execute: cp wb collect mon ../misc.Verify: ls ../misc now shows wb, collect, mon.

Verification / Alternative check:Try copying with wildcards (e.g., cp w* if patterns match). Use cp -i to prompt before overwrite or cp -v for verbose output.

Why Other Options Are Wrong:Option A uses DOS syntax (copy), not UNIX cp, and repeats the destination unnecessarily.Option C again uses DOS copy and an absolute path /misc that likely is not intended.Option D uses tar, which is for archiving, not simple copying to a directory argument.

Common Pitfalls:

  • Confusing absolute /misc with relative ../misc.
  • Overwriting existing files without -i or backups.

Final Answer:cp wb collect mon ../misc

Discussion & Comments
No comments yet. Be the first to comment!
Join Discussion