Problem: In Mobaxterm's bash console running commands in a shell script fail while the same command runs from the command line.
observation: It seems that the bash running inside of the MobaXterm terminal inside windows is "enhanced" by some busybox wrapper as a result commands typed in the terminal are different from the same commands called from a script in the terminal...
example: xargs supports the -I option on the command line, but if you save the same command in a shell script and execute it, it fails... it looks like xargs on ther prompt is a builtin command different from the file itself...
27/05/2021 13:50.30 /home/mobaxterm echo foo |xargs -I{} echo {}
foo ✔
27/05/2021 13:50.45 /home/mobaxterm echo "echo foo |xargs -I{} echo {}">bar.sh
✔
27/05/2021 13:51.17 /home/mobaxterm chmod 755 bar.sh
✔
27/05/2021 13:51.26 /home/mobaxterm ./bar.sh
xargs: unknown option -- I
BusyBox v1.22.1 (2015-11-10 11:07:12 ) multi-call binary.
Usage: xargs [OPTIONS] [PROG ARGS]
Run PROG on every item given by stdin
-p Ask user whether to run each command
-r Don't run command if input is empty
-0 Input is separated by NUL characters
-t Print the command on stderr before execution
-e[STR] STR stops input processing
-n N Pass no more than N args to PROG
-s N Pass command line of no more than N bytes
-x Exit if size is exceeded
✘
27/05/2021 13:51.33 /home/mobaxterm m
27/05/2021 13:42.57 /home/mobaxterm xargs --version
xargs (GNU findutils) 4.6.0
Packaged by Cygwin (4.6.0-1)
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Eric B. Decker, James Youngman, and Kevin Dalley.
✔
27/05/2021 13:43.17 /home/mobaxterm which xargs
/bin/xargs
✔
27/05/2021 13:43.23 /home/mobaxterm /bin/xargs --version
xargs: unknown option -- version
BusyBox v1.22.1 (2015-11-10 11:07:12 ) multi-call binary.
Usage: xargs [OPTIONS] [PROG ARGS]
Run PROG on every item given by stdin
-p Ask user whether to run each command
-r Don't run command if input is empty
-0 Input is separated by NUL characters
-t Print the command on stderr before execution
-e[STR] STR stops input processing
-n N Pass no more than N args to PROG
-s N Pass command line of no more than N bytes
-x Exit if size is exceeded
✘
27/05/2021 13:43.28 /home/mobaxterm
I am guessing that you've solved your problem since then, but since I had the same problem, I thought to post it here for others. I searched for xargs in the available packages for mobaxterm.
apt-get search xargs
- Found command "xargs" in package "findutils"
➤ You can install this package by using the following command:
apt-get install findutils
apt-get searchdesc xargs
- Found description "Utilities for finding files--find, xargs, locate, updatedb" in package "findutils"
➤ You can install this package by using the following command:
apt-get install findutils
After installing this, it worked.