Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to use xargs to list details of files passed from echo.
Linux CLI
echo file1.txt file2.txt | xargs [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
cat instead of ls -l will show file contents, not details.Using
rm will delete files, which is not intended here.✗ Incorrect
The
ls -l command lists detailed information about files. Using xargs with ls -l runs ls -l on each file passed from echo.2fill in blank
mediumComplete the code to delete files listed in files.txt using xargs.
Linux CLI
cat files.txt | xargs [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
ls will only list files, not delete them.Using
mkdir or touch will create directories or files, not delete.✗ Incorrect
The
rm command deletes files. Using xargs rm deletes all files listed in files.txt.3fill in blank
hardFix the error in the code to correctly count lines in files listed by find using xargs.
Linux CLI
find . -name '*.txt' | xargs [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
ls -l lists file details but does not count lines.Using
cat outputs file contents but does not count lines.✗ Incorrect
The
wc -l command counts lines in files. Using xargs wc -l counts lines in all .txt files found.4fill in blank
hardFill both blanks to create a command that finds all .log files and compresses them using gzip.
Linux CLI
find /var/log -name '*.log' | xargs [1] [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
ls does not compress files.Using
-9 is a compression level but not required here.✗ Incorrect
The
gzip command compresses files. The -v option shows verbose output. Using xargs gzip -v compresses all found .log files with visible progress.5fill in blank
hardFill all three blanks to create a command that finds all .txt files, counts words in each, and shows only those with more than 100 words.
Linux CLI
find . -name '*.txt' | xargs [1] | awk '[2] [3] 100'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
ls does not count words.Using wrong comparison operators like
< will filter incorrectly.✗ Incorrect
The
wc -w command counts words. The awk command filters lines where the first field (word count) is greater than 100. This combination lists files with more than 100 words.