i need help. trying to pipe filepath into xargs and escape single quote, but -0 option not working. i don’t have access to -d option as i am on macOS.


alias lst "!cat ${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection | xargs -0 -I fname echo "put" \'fname\' > files.lftp"

@brennen when passing a filename such as Datach'i - Bonus - 01 Aldebaran.mp3 the single quote breaks up the filename

@gavcloud quoting (as i've recently discovered) can get unexpectedly weird in aliases, so a function might be a better idea, but i'll see if i can come up with a useful alternative...

@brennen been scratching my head. thanks for taking a look into. curious for your findings.

@gavcloud so i'm not sure how helpful this is: on my debian and i'm guessing that lftp also wants that single quote escaped, so my assumptions may be invalid at a couple of points.

@brennen i think I need to implement the differently as calling it within lftp is giving errors.

lftp : ftp_user@server://home/user/home/TEST> lst
Unknown command `function'.
Unknown command `sed'.
Unknown command `do'.
Unknown command `printf'.
Unknown command `done'.
Unknown command `}'.

@gavcloud hmm - i haven't tried running scripts from inside of lftp before, but this version will run as a standalone shell script:

#!/usr/bin/env bash
echo -n '' > files.lftp
sed "s/'/\\\'/" example_selection | while read -r fname; do
printf "put '%s'\n" "$fname" >> files.lftp

@brennen yes this is great for me to unpack as i learn more about bash. tysm! might even be able to call this script as before via alias in .lftprc and run all within lftp

@gavcloud glad to help!

(i'm going offline for the night, but if that doesn't get you there, maybe leave me a quick outline of what you want to do (i think it's "upload files listed in an nnn selection to somewhere", but i might be making some guesses) and a sample selection file and i can document you a more robust solution at some point.)

@brennen yeah you pretty much got it. I want to connect to a server after making file selections inside of and just pass that list into the server via mv command. It's essentially working as intended except for this use case with the single-quote (and possibly other I have yet to test).

@brennen thank you so much. my next step is to see how to make lst executable when lftp is loaded and then to see if I can pass it the selection file to replace your example_selection. very clear + much appreciated.

Sign in to participate in the conversation

SoNoMu (Sound Noise Music) is a mastodon instance for musicians, sound-artists, producers of any kind of aural noise, songwriters, bedroom producers, sonic manglers and algorave livecoders. -> more...