Modifying replace string in xargs

The following command constructs the move command with xargs, replaces the second occurrence of ‘.’ with ‘.bar.’, then executes the commands with bash, working on mac OSX. ls *.txt | xargs -I {} echo mv {} foo/{} | sed ‘s/\./.bar./2’ | bash

How to use > in an xargs command?

Do not make the mistake of doing this: sh -c “grep ABC {} > {}.out” This will break under a lot of conditions, including funky filenames and is impossible to quote right. Your {} must always be a single completely separate argument to the command to avoid code injection bugs. What you need to do, … Read more

Calling shell functions with xargs

Exporting the function should do it (untested): export -f echo_var seq -f “n%04g” 1 100 | xargs -n 1 -P 10 -I {} bash -c ‘echo_var “$@”‘ _ {} You can use the builtin printf instead of the external seq: printf “n%04g\n” {1..100} | xargs -n 1 -P 10 -I {} bash -c ‘echo_var “$@”‘ … Read more

How can I use xargs to copy files that have spaces and quotes in their names?

You can combine all of that into a single find command: find . -iname “*foobar*” -exec cp — “{}” ~/foo/bar \; This will handle filenames and directories with spaces in them. You can use -name to get case-sensitive results. Note: The — flag passed to cp prevents it from processing files starting with – as … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)