Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • Note you can use ~ fine in POSIX sh, no need to switch $HOME. In some shells ~ can expand to the user's home even when $HOME is not defined. See the -d '\n' option of GNU xargs to make one argument out of each line. Commented Mar 17 at 6:56
  • In the last one, mv's -i won't work properly as stdin will be either filelist.txt or /dev/null (the latter with GNU xargs). See xargs -rd '\n' -a filelist.txt bash -c '...' bash with GNU xargs to avoid the issue. Commented Mar 17 at 7:00
  • @StéphaneChazelas Thanks. I'll remove the -i from all code. The original code in the question didn't have it anyway. Commented Mar 17 at 7:26
  • @StéphaneChazelas As for the tilde, it's a habit of mine to use tilde on the command line by the variable in scripts. If the variable is undefined in a script, then that's an appropriately serious issue that warrants a script to fail. Commented Mar 17 at 7:34
  • mv might still prompt the user even without -i which would cause problems in those xargs implementations that don't reopen stdin on /dev/null. You could add a </dev/null within the bash code if you don't want to introduce more GNUisms. Commented Mar 17 at 8:09