-
-
Save TheBigFish/f5538202e02e51f5f3b6f972c29ce9c9 to your computer and use it in GitHub Desktop.
use xargs with bash function
This file contains hidden or 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 hidden or 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