Bash Snippet: Move list of files from stdin
Tonight I had a list of filenames copied on my local computer and wanted to move them in an ssh session. Here’s how I did it:
cat | while read line; do mv "$line" destination_directory; done
After hitting enter, you can paste in a list and each line will be used in the mv command. cat, by itself, reads from stdin, and this is piped to the while read. Send Ctrl+D (End of File) to exit out of cat. Super handy, and it only took me like a freaking hour to figure out!