Monday, April 29, 2024
 Popular · Latest · Hot · Upcoming
0
rated 0 times [  0] [ 0]  / answers: 1 / hits: 2067  / 2 Years ago, wed, january 26, 2022, 12:54:01

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?


More From » bash

 Answers
7

This worked for me:



alias csl='awk '''{print "047"$1"047"}''' | paste -d, -s'


Thanks to @roadmr for pointing me in the right direction.


[#36259] Thursday, January 27, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
panshow

Total Points: 454
Total Questions: 98
Total Answers: 122

Location: Philippines
Member since Sat, Jul 11, 2020
4 Years ago
;