1.

What is the correct syntax for copying multiple files with a filename starting as ‘file’ into another file named as‘directory_one’?(a) cp -i filedirectory_one(b) cp -R filedirectory/directory_one(c) cp file*directory_one(d) none of the mentionedI have been asked this question in an internship interview.Origin of the question is Copying a File: cp Command topic in chapter Handling Ordinary Files of Unix

Answer»

The correct ANSWER is (c) cp FILE*directory_one

Easy explanation: For copying multiple files with a common starting name such as (file, FILE001, file.txt, fileone.jpg, file-archive.zip) we use (“*”). An asterisk (“*”) is a wildcard – a special CHARACTER which EXPANDS to match other characters.For example,cp file*directory_one will copy all the files whose name will be starting with ‘file’into‘directory_one’ file.



Discussion

No Comment Found

Related InterviewSolutions