← 返回命令列表

Linux command

xe 命令

文本

涉及管道、覆盖或删除,执行前请先确认路径和参数。

常用示例

Run command for each line of stdin

cat [list.txt] | xe [command]

Use {} as placeholder for the argument

cat [list.txt] | xe [command] {}

Parallel execution with N jobs

cat [urls.txt] | xe -j [4] curl {}

Pass arguments directly after --

xe -a -- mv {} {}.bak -- [file1] [file2]

Null-separated input (for filenames with spaces)

find . -print0 | xe -0 echo {}

Pass up to N arguments per command

xe -N [10] rm -- [*.txt]

Dry-run: print commands without executing

cat list.txt | xe -n [command] {}

说明

xe is a tool for constructing command lines from file listings or arguments, combining the best features of xargs(1) and apply(1). By default it runs the given command once per input line, substituting {} with the argument, making common use cases simpler than xargs. Unlike xargs, xe has sane defaults: it is equivalent to `xargs -d'\n' -I{} -n1 -r`. Arguments can be read from stdin (default), from a file with -f, or directly from the command line after -a. xe supports parallel execution with -j, make-style percent rule matching with -p, and can invoke a shell script per argument with -s.

参数

-0
Input arguments are separated by NUL bytes instead of newlines. Useful with `find -print0`.
-a
Take arguments from the command line (after the command, separated by --) instead of stdin.
-A _argsep_
Use a custom argument separator instead of -- (implies -a).
-f _argfile_
Read arguments from _argfile_ instead of stdin.
-F
Fatal: stop and exit when a command execution fails.
-I _replace-arg_
Set the replacement string (default: {}).
-j _maxjobs_
Run up to _maxjobs_ processes concurrently.
-L
Line-buffered output so lines from concurrent jobs do not interleave.
-N _maxargs_
Pass up to _maxargs_ arguments to each command invocation (default: 1).
-n
Dry-run: print the commands that would be executed without running them.
-p
Make-style percent rule matching for pattern-dispatched commands.
-q
Quiet: redirect stdout/stderr of commands to /dev/null.
-R
Return exit status 122 when no arguments are supplied (instead of 0).
-s _shellscript_
Execute _shellscript_ via the shell; arguments are available as $1, $2, etc.
-v
Verbose: print commands to stderr before running them.

FAQ

What is the xe command used for?

xe is a tool for constructing command lines from file listings or arguments, combining the best features of xargs(1) and apply(1). By default it runs the given command once per input line, substituting {} with the argument, making common use cases simpler than xargs. Unlike xargs, xe has sane defaults: it is equivalent to `xargs -d'\n' -I{} -n1 -r`. Arguments can be read from stdin (default), from a file with -f, or directly from the command line after -a. xe supports parallel execution with -j, make-style percent rule matching with -p, and can invoke a shell script per argument with -s.

How do I run a basic xe example?

Run `cat [list.txt] | xe [command]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -0 do in xe?

Input arguments are separated by NUL bytes instead of newlines. Useful with `find -print0`.