Bash - Strings, comandos e escapes (oh, que coisa!)
Estou perdendo muito tempo agora tentando descobrir algo tão simples ....
pseudo-código (mistura de várias sintaxes, desculpe):
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 */ }
isso funciona....
FIND=$(find $LOG_DIR -type f | grep -v -f $EXCLUDE | nl -ba -s' ')
printf "%s\n" "$FIND"
isso não ...
NL="nl -ba -s' '"
FIND=$(find $LOG_DIR -type f -mtime +$ARCH_AGE | grep -v -f $EXCLUDE | $NL)
printf "%s\n" "$FIND"
e nem isso ...
NL='nl -ba -s'\'' '\'' '
isso definitivamente funciona, no entanto:
find /my/starting/path -type f | grep -v -f /my/exclude/files | nl -ba -s' '
ou
FIND=$(find $LOG_DIR -type f -mtime +$ARCH_AGE | grep -v -f $EXCLUDE | nl -ba -s' ' )