Bash - Strings, Commands und Escaping (oh, my!)

Ich verschwende gerade so viel Zeit, um etwas so Einfaches herauszufinden ....

pseudocode (Mischung aus mehreren Syntaxen, sorry):

cmd1 = "find /my/starting/path -type f | grep -v -f /my/exclude/files"
cmd2 = " nl -ba -s'  ' "
cmd3 = " | xargs mv -t /move/here/dir " 

echo run_command_and_return_output($cmd1$cmd2)

$cmd1$cmd3  # just this now... 

# i don't actually want a function... but the name explains what i want to do
function run_command_and_return_output(){ /* magic */ }

das funktioniert...

FIND=$(find $LOG_DIR -type f | grep -v -f $EXCLUDE | nl -ba -s'   ')

printf "%s\n" "$FIND"

das tut nicht..

NL="nl -ba -s'  '"
FIND=$(find $LOG_DIR -type f -mtime +$ARCH_AGE | grep -v -f $EXCLUDE | $NL)

printf "%s\n" "$FIND"

und das auch nicht ...

NL='nl -ba -s'\''   '\'' '

dies funktioniert auf jeden Fall, aber:

find /my/starting/path -type f | grep -v -f /my/exclude/files |  nl -ba -s'  ' 

ode

FIND=$(find $LOG_DIR -type f -mtime +$ARCH_AGE | grep -v -f $EXCLUDE | nl -ba -s'  ' )

Antworten auf die Frage(1)

Ihre Antwort auf die Frage