Module 6 challenge: Edit Files Using Substrings :Using Python to Interact with the Operating System (Google IT Automation with Python Professional Certificate) Answers 2025
1. Linux command to create/view/concatenate files
❌ grep
✔️ cat
❌ cut
❌ overwrite
2. Command to extract specific columns from a file
❌ cp
✔️ cut
❌ cat
❌ grep
3. When is the -d option needed in cut?
❌ When there is a range of fields
❌ When there is a set of fields
❌ When there are text strings
✔️ When fields are separated by delimiters
4. Effect of double greater than sign (>>) on existing file content
❌ Delete the file content
✔️ Append the file content
❌ Duplicate the file content
❌ Overwrite the file content
5. What happens if the target file doesn’t exist for cat > [file] or cat >> [file]?
❌ Redirection command terminates
✔️ A new file with the same name will be created
❌ Input/output error
❌ Append content in an existing file
6. Command to check if a file is present
❌ cat
❌ cut
❌ overwrite
✔️ test
7. Difference between -f 1-3 and -f 1,3
❌ First is cut and second is cat
❌ No difference
✔️ First specifies fields 1 through 3, second specifies fields 1 and 3
❌ First specifies fields 1 and 3, second specifies fields 1 through 3
8. Effect of > help.txt
❌ Erase existing file content
❌ Check if file exists
❌ Flag existing content to be amended
✔️ Create an empty file named help.txt
9. Command to create oldFiles.txt
✔️ > oldFiles.txt
❌ cd ~/oldFiles.txt
❌ # oldFiles.txt
❌ >> oldFiles.txt
10. What is a “for” loop in Bash?
❌ Execute instructions as long as control condition is specified
❌ Execute as long as control condition remains false
✔️ Execute a group of statements over a set of items
❌ Execute as long as control condition remains true
📌 Summary Table
| Q# | Correct Answer(s) |
|---|---|
| 1 | cat ✔️ |
| 2 | cut ✔️ |
| 3 | -d used when fields separated by delimiters ✔️ |
| 4 | Append content ✔️ |
| 5 | New file created ✔️ |
| 6 | test ✔️ |
| 7 | 1-3 vs 1,3 ✔️ |
| 8 | Create empty file ✔️ |
| 9 | > oldFiles.txt ✔️ |
| 10 | Group of statements over a set of items ✔️ |