Command One Liners

I often want to take the contents of my Windows clipboard and paste it into a session to a Linux or UNIX machine, by using it as input for a program.
The problem I usually encounter is that the clipboard is several lines of text with a New Line or Return character at the end of each line. This is not great if you want to run:
mycommand line1
mycommand line2

I've whipped up a little command line one liner that will take standard input and use that in a command:
read i; while [ "$i" != "EOF" ]; do echo $i; mycommand $i; read i; done
This will echo each line of input before running mycommand. This helps in resolving any issues with mycommand.

Comments

Post new comment