← Learn
Safe
find ./logs -type f -name '*.log' -mtime +7 -print0 | xargs -0 -P 4 -I{} sh -c 'gzip -9 "$1"' _ {}

linux · bash · Nightmare

Compresses week-old log files in the current project four at a time. It has every shape that should worry you — a pipeline, sh -c, an argument placeholder — yet the inner command is only gzip, the path is relative, and the underscore correctly consumes $0 so filenames land in $1.

Think you can spot these under time pressure?

Start Training

More Shell