Format stdin in bash

Posted by User1 on Stack Overflow See other posts from Stack Overflow or by User1
Published on 2010-05-04T02:07:30Z Indexed on 2010/05/04 2:18 UTC
Read the original article Hit count: 242

Filed under:

I have a multi-line string coming from another program that I want to convert to a SQL command. I was hoping that printf could help me, but it doesn't seem to work:

echo -e '1\n2\n3'|printf 'SELECT %s INTO MyTable'

I was hoping to see:

SELECT '1
2
3' INTO MyTable

But I got:

SELECT  INTO MyTable

How can I get the %s to read stdin?

© Stack Overflow or respective owner

Related posts about bash