I am always typing things like this:
cat some_list_of_elements.txt | awk '{print "\047"$1"\047"}' | paste -d, -s
It takes a list of items from a file, wraps each in quotes, and merges them together in a comma-separated list.
Rather than typing out all that stuff, I'd like to do something like this:
cat some_list_of_elements.txt | csl
How can csl be implemented in bash? Is there a way to do it as an alias?
alias csl='awk '\''{print "\047"$1"\047"}'\'' | paste -d, -s'– frankadelic Aug 09 '12 at 22:15csl() { awk '{print "\047" $1 "\047"}' - | paste -d, -s; }-- don't have to mess around with a lot of quotes and backslashes. I explicitly put the argument-for awk to denote that it's reading from stdin. – glenn jackman Aug 10 '12 at 00:36$1is getting substituted at the time you're defining the alias. – glenn jackman Aug 10 '12 at 00:37