Questions
Questions

FA25_ISOM_661_4102 Shell - MC Quiz

Single choice

You want to write a shell script that: Creates a directory called backup, if it doesn't already exist, and Copies all .txt files from the current directory into the backup directory.   Which of the following code snippets (if any) will achieve this?

Options
A.mkdir -p backup cp *.txt backup/
B.None of the other answers is correct
C.mkdir backup cp *.txt backup/
D.if [ ! -d "backup" ]; then   mkdir backup fi cp *.txt backup/
E.if [ -d "backup" ]; then   mkdir backup fi cp *.txt backup/
View Explanation

View Explanation

Verified Answer
Please login to view
Step-by-Step Analysis
Question: You want to write a shell script that: Creates a directory called backup, if it doesn't already exist, and Copies all .txt files from the current directory into the backup directory. Which of the following code snippets (if any) will achieve this? Options: 1) mkdir -p backup cp *.txt backup/ 2) None of the other answers is correct 3) mkdir backup cp *.txt backup/ 4) if [ ! -d "backup" ]; then mkdir backup fi cp *.txt backup/ 5) if [ -d "backup" ]; then mkdir backup fi cp *.txt backup/ Analysis of each option: Option 1: mkdir -p backup cp *.txt backup/ - The -p flag in mkdir ensures that the directory is created if it does not exist and does nothing i......Login to view full explanation

Log in for full answers

We've collected over 50,000 authentic exam questions and detailed explanations from around the globe. Log in now and get instant access to the answers!

More Practical Tools for Students Powered by AI Study Helper

Join us and instantly unlock extensive past papers & exclusive solutions to get a head start on your studies!