/media/bill/HOWELL_BASE/System_maintenance/Linux/xargs notes.txt ********************* 05Aug2018 example from +-----+ grep all files in a directory (shows error for directories, scary when no matches): $ cd "/media/bill/PROJECTS/Lucas - Universal Force/" $ grep --with-filename --line-number "symbols grep-sed.sh" * OR BETTER : $ find "/media/bill/PROJECTS/Qnial/MY_NDFS/" -maxdepth 1 -name "*" | tr \\n \\0 | xargs -0 -IFILE grep --with-filename --line-number "sym_stdForm" "FILE" qnial> host link 'find "/media/bill/ramdisk" -maxdepth 1 -name "emSplit *" -printf "%f\n" | tr \\n \\0 | xargs -0 -IFILE mv "' d_QNial_temp 'FILE" "' d_archive timestamp_YYMMDD ' FILE.arc" ' ; $ find "/media/bill/ramdisk" -maxdepth 1 -name "emSplit *" -printf "%f\n" | tr \\n \\0 | xargs -0 -IFILE echo "/media/bill/ramdisk/FILE" "/media/bill/PROJECTS/a_INNS Lexicom email server/z_Archive/181015 FILE.arc" ******************* 17Jul2018 from "/media/bill/PROJECTS/Qnial/MY_NDFS/symbols grep count.sh" *******************(( 23May2018 xargs using piped args as variables taken from "/media/bill/SWAPPER/bin/email - process folders.sh" # Create script to grep addresses from email folders #ls -1 "$d_folder" | grep --invert-match ".msf" | grep --invert-match ".txt" | tr \\n \\0 | xargs -0 --max-args=1 -I email_folder echo >>"$p_scriptGrep" 'grep -o "\([-A-Za-z0-9._]\+\)\(@\)\([-A-Za-z0-9._]\+\)" "'"$d_folder"'email_folder" >>"'"$d_folder"'email_folder.txt" ' #>> OK ********************* 12Jan2018 search "Linux and xargs build a command" # https://www.systutorials.com/docs/linux/man/1-xargs/ # I didn't really use the URL, just man xargs, but it still helped force me to think it through Howell's example in "/media/bill/SWAPPER/bin/start_app.sh" # xargs_it $1 $2 $3 $4 # delay command options argument_string xargs_it() { #echo "\"$3\" &" | xargs "$2" echo "\"$4\"" | xargs "$2" "$3" sleep "$1" } # test - comment out "app_start" below, and visa versa # $ bash "/media/bill/SWAPPER/bin/start_app.sh" # These examples work!! #xargs_it "1s" "ls" "-1" "\"/media/bill/SWAPPER/bin\"" #xargs_it "1s" "gnome-terminal" "" "" xargs_it "1s" "nemo" "" "/media/bill/SWAPPER/Lucas - Universal Force" ********************* 11Jan2018 xargs can't find a file that DOES exist!! xargs: /media/bill/SWAPPER/bin/start_input.sh : No such file or directory - is this because "SWAPPER" is Windows format? >> original if [ "$line_input" != "q" ]; then echo "$line_input" | tr '[:blank:]' '\n' | xargs --max-args=1 "$d_start""start_input.sh" fi >> next just use full path if [ "$line_input" != "q" ]; then echo "$line_input" | tr '[:blank:]' '\n' | xargs --max-args=1 "/media/bill/SWAPPER/bin/start_input.sh" fi >> take out quotes if [ "$line_input" != "q" ]; then echo "$line_input" | tr '[:blank:]' '\n' | xargs --max-args=1 /media/bill/SWAPPER/bin/start_input.sh fi >> all above attempts fail Check that the script is executable : >> NO!! and I can't change the permission! see my previous conclusion in "/media/bill/HOWELL_BASE/System_maintenance/Linux/chown notes.txt" Dec2017? IMPORTANT! : Chown & chmod don't work well on Fat32 etc formated drives!!! search "Linux and xargs use of files on Fat32" https://shapeshed.com/unix-xargs/ good overall description https://unix.stackexchange.com/questions/100968/weird-no-such-file-error-with-xargs-and-file The command substitution $(file --mime-type -b FILE) is executed by the shell before being passed to xargs, which is why you are not seeing what you need. Quote $(file --mime-type -b FILE) and pass it to bash -c via xargs find . -type f | xargs -n 1 -I FILE bash -c 'echo $(file --mime-type -b FILE)' answered Nov 13 '13 at 3:47, iruva >> INTERESTING! - try it >> NYET!!! solution was simple :just bash it if [ "$line_input" != "q" ]; then echo "$line_input" | tr '[:blank:]' '\n' | xargs --max-args=1 bash "$d_start""start_input.sh" fi +-----+ This is extreme but, What I can do is copy entire "/media/bill/SWAPPER/bin/" directory to "/home/bill/bin" as part of "/home/bill/start" *************** ?dates? >> my example to touch many files in "/media/bill/HOWELL_BASE/bin/cp-mv general.sh" : # for testing - make destination files older : # $ find "/home/bill/Raspberry Pi/" -maxdepth 1 -type f | grep "160513" | sed 's/^/"/' | sed 's/$/"/' | xargs --max-args=1 touch -mc -t 201701151245.15 https://www.cyberciti.biz/faq/linux-unix-bsd-xargs-construct-argument-lists-utility/ xargs: How To Control and Use Command Line Arguments Posted on February 17, 2009in Categories BASH Shell, CentOS, Debian / Ubuntu, File system, FreeBSD, KSH Shell, Openbsd, RedHat and Friends, Solaris-Unix, Ubuntu Linux, UNIX last updated September 2, 2010 Posted by: Vivek Gite $ find . -iname "*.mp3" -print0 | xargs -0 -I mp3file mplayer mp3file https://stackoverflow.com/questions/15976570/is-there-a-grep-equivalent-for-finds-print0-and-xargss-0-switches The newest version of the GNU grep source can now use -z/--null to separate the output by null characters, while it previously only worked in conjunction with -l: http://git.savannah.gnu.org/cgit/grep.git/commit/?id=cce2fd5520bba35cf9b264de2f1b6131304f19d2 This means that your issue is solved automatically when using the newest version. answered Mar 18 '16 at 17:11, Chiel ten Brinke http://www.thegeekstuff.com/2013/12/xargs-examples 10 Xargs Command Examples in Linux / UNIX by Himanshu Arora on December 26, 2013 >> not so useful for what I was doing ************ $ man xargs --null -0 Input items are terminated by a null character instead of by whitespace, and the quotes and back‐ slash are not special (every character is taken literally). Disables the end of file string, which is treated like any other argument. Useful when input items might contain white space, quote marks, or backslashes. The GNU find -print0 option produces input suitable for this mode. -L max-lines Use at most max-lines nonblank input lines per command line. Trailing blanks cause an input line to be logically continued on the next input line. Implies -x. --max-lines[=max-lines] -l[max-lines] Synonym for the -L option. Unlike -L, the max-lines argument is optional. If max-lines is not specified, it defaults to one. The -l option is deprecated since the POSIX standard specifies -L instead. --verbose -t Print the command line on the standard error output before executing it. --exit -x Exit if the size (see the -s option) is exceeded. # enddoc