 <pre><code>$ cat test.txt abc def ghi jkl mno $ cat test.txt | tr '\n' ',' abc,def,ghi,jkl,mno, $ cat test.txt | awk '{print "\x27" $1 "\x27"}' | tr '\n' ',' 'abc','def','ghi','jkl','mno', $ cat test.txt | awk '{print "\x27" $1 "\x27"}' | tr '\n' ',' | sed 's/,$//' 'abc','def','ghi','jkl','mno' </code></pre> <p>The last command can be shortened to avoid <a href="http://partmaps.org/era/unix/award.html" rel="nofollow">UUOC</a>:</p> <pre><code>$ awk '{print "\x27" $1 "\x27"}' test.txt | tr '\n' ',' | sed 's/,$//' 'abc','def','ghi','jkl','mno' </code></pre>