xargs 的示例代码怎么写

2023-04-09 19:53:00 代码 示例 xargs

xargs 的示例代码怎么写

xargs 的示例代码如下:

#!/bin/bash # This is a simple xargs example # Run this script with: # ./xargs_example.sh # Or use it like this: # seq 5 | xargs ./xargs_example.sh # Or use it with find and exec like this: # find . -name "*.txt" -exec ./xargs_example.sh {} \; # Or use it with grep like this: # grep -l "something" * | xargs ./xargs_example.sh # Or use it with sed like this: # sed -n '/something/p' * | xargs ./xargs_example.sh # Or use it with awk like this: # awk '/something/ {print $0}' * | xargs ./xargs_example.sh # Or use it with tr like this: # tr '[:upper:]' '[:lower:]' * | xargs ./xargs_example.sh # Or use it with wc like this: # wc -l * | xargs ./xargs_example.sh # Or use it with bc like this: # echo "2^32" | bc | xargs ./xargs_example.sh # Or use it with perl like this: # perl -e 'for(1..1000){print int(rand(1000)),"

"}' | xargs ./xargs_example.sh # Or use it with python like this: # python -c "import random; print '

'.join([str(random.randint(0, 1000)) for i in range(1000)]);" | xargs ./xargs_example.sh input="$@" if [ -z "$input" ]; then echo "No input provided" exit 1 fi echo "You provided the following input: $input"

相关文章