File and Text Manipulation

6. In Bash, which of the following commands can be used to view the contents of a document? Check all that apply.

  • less
  • gat
  • dog
  • cat

7. A Linux machine has the following files:

apple.txt

banana.jpg

chocolate.txt

orange.txt

What command can be used to search for the word "fruit" in the text files? Check all that apply.

  • find fruit apple.txt chocolate.txt orange.txt
  • grep fruit apple.txt chocolate.txt orange.txt
  • grep fruit *.txt
  • find fruit apple.txt chocolate.txt

8. In Bash, which of the following commands can be used to view a list of all files in the /home directory? Check all that apply.

  • ls -la /home
  • ls -l -a /home
  • list -a /home
  • ls -la ~

9. A Linux machine has a file named "types_of_fish.txt". Which of the following commands can be used to append the word "trout" to the file contents?

  • echo trout > types_of_fish.txt
  • echo trout < types_of_fish.txt
  • echo trout >> types_of_fish.txt
  • echo trout 2> types_of_fish.txt

10. Using a linux machine, which of the following commands can be used to list through a directory called /home/ben/Documents and search for the word "important" in the filenames in that directory?

  • ls /home/ben/Documents< grep important
  • ls /home/ben/Documents >> grep important
  • ls /home/ben/Documents > grep important
  • ls /home/ben/Documents | grep important

11. Which command can be used on Windows CLI to see the first 10 lines of a file called “more_information.txt”?

  • ls more_information.txt -head 10
  • less more_information.txt -head 10
  • head more_information.txt
  • cat more_information.txt -head 10

Devendra Kumar

Project Management Apprentice at Google

Leave a Reply