Section: xargs

Use a placeholder in the command

bash
bash
printf '%s
' app1 app2 | xargs -I{} kubectl logs {}
Explanation

`-I{}` substitutes each input item wherever the placeholder appears.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing xargs
Pass stdin items as arguments
Convert lines into command arguments.
OpenIn sheetbashsame section
Use null-delimited input
Handle spaces and special characters safely.
OpenIn sheetbashsame section
Run one item per command
Invoke the command once per input line.
OpenIn sheetbashsame section
Run commands in parallel
Process multiple input items concurrently.
OpenIn sheetbashsame section
Replace text across many files safely
Search files first, then edit in place.
OpenIn sheetbash1 tag match
Split a file by line count
Create chunks of 1000 lines each.