I would like xargs
to handle the long file path I got from find
, but the -I option does not work
Commands Executed
path="What's wrong with you? What's wrong with you? What's wrong with you? What's wrong with you? What's wrong with you? What's wrong with you? What's wrong with you? What's wrong with you? What's wrong with you?
echo "path:${path}"
find"${path}"-mindepth1-maxdepth1-print0 | xargs-0-n1-P10 echo
find "${path}"-mindepth1-maxdepth1-print0 | xargs-0-n1-P10-I{}bash-c "echo{}"
Run Results
$bash./test.sh
path: aye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye-ye
Aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye.DS_Store
Aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye, aye.
{}
{}
As mentioned above, the replacement does not work, and for some reason {}
is displayed as it is.
Why is that?
The running environment is masOS Sierra 10.12.6.
Thank you for your cooperation.
For macOS xargs, the maximum string after replacement with the -I option appears to be 255 bytes.
According to man xargs
:
I replstr
Execute utility for each input line, replacing one or more occurrences of replacement in up to replacements (or 5 if no-R flag is specified) arguments to utility with the entry line of input.The
resulting arguments, after replacement is done, will not be allowed to grow Beyond 255 bytes; this implemented by concatenating as much of the argument containing replaceable, to the
constructed arguments to utility, up to 255 bytes. The 255 byte limit does not apply to arguments to utility which do not contain replstr, and further, no replacement will be done on utility
itsself.Implies-x.
915 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
578 Understanding How to Configure Google API Key
612 GDB gets version error when attempting to debug with the Presense SDK (IDE)
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
© 2024 OneMinuteCode. All rights reserved.