Last active
October 10, 2023 11:05
-
-
Save UniIsland/f2e2a92f1b30eeab06eadf5eb83baa56 to your computer and use it in GitHub Desktop.
use xargs with bash function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
parse_and_echo() { | |
echo "\$1:$1 \$2:$2 \$3:$3 \$4:$4" | |
echo newline | |
} | |
export -f parse_and_echo | |
# `_' is placeholder for $0 | |
cat ./xargs_with_function.txt | xargs -n 4 bash -c 'parse_and_echo $@' _ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 12 13 14 | |
21 22 23 24 | |
31 32 33 34 | |
41 42 43 44 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment