0
0
Linux CLIscripting~10 mins

xargs for building commands from input in Linux CLI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete 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'
Als -l
Bcat
Crm
Dmkdir
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.
2fill in blank
medium

Complete 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'
Arm
Bls
Cmkdir
Dtouch
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.
3fill in blank
hard

Fix 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'
Als -l
Bwc -l
Ccat
Drm
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.
4fill in blank
hard

Fill 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'
Agzip
B-v
C-9
Dls
Attempts:
3 left
💡 Hint
Common Mistakes
Using ls does not compress files.
Using -9 is a compression level but not required here.
5fill in blank
hard

Fill 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'
Awc -w
B$1
C>
Dls
Attempts:
3 left
💡 Hint
Common Mistakes
Using ls does not count words.
Using wrong comparison operators like < will filter incorrectly.