101-500 Exam QuestionsBrowse all questions from this exam

101-500 Exam - Question 52


What is true regarding the command

ls > files

if files does not exist?

Show Answer
Correct Answer: B

The command 'ls > files' redirects the standard output of the 'ls' command to a file named 'files'. If 'files' does not exist, it will be created and will contain the output of 'ls'. This behavior is due to the redirection operator '>', which directs the output to a file and creates the file if it does not already exist.

Discussion

7 comments
Sign in to comment
jeggaOption: B
May 28, 2021

B is the correct answer confirmed on RedHat

tzahiOption: B
Mar 21, 2022

Simple redirection: > Will write stdout to a file ( if the file exists it will overwrite it) >> Will append stdout to a file ( write to next line after the original data ends ) Both will create the file is it doesn't exist

UntakedOption: B
Mar 23, 2022

B root@LAPTOP-57VPBVH8:~# ls > files root@LAPTOP-57VPBVH8:~# ls README.md files root@LAPTOP-57VPBVH8:~# cat files README.md files

CuriousLinuxCatOption: B
Jul 3, 2021

B is the correct answer. Confirmed with CoCalc website running Ubuntu.

LazylinuxOption: B
Apr 21, 2022

yep it is Bee

ebo07Option: B
Dec 22, 2021

B is correct. Tested on Xubuntu

NinymoOption: B
Mar 24, 2024

Answer: B