brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: paste -sd, joins lines into one comma separated terminal line

Terminal
~/tips/tip-terminal-paste-sd-join-lines

printf '%s\n' alpha beta gamma | paste -sd, -

Joins every input line into one line with a chosen separator.

Turning a list into one line used to be a job for a loop or a sed trick.

printf '%s\n' alpha beta gamma | paste -sd, -

-s pastes all lines of one file into a single line, -d, sets the delimiter, and the final - means standard input. The result is alpha,beta,gamma. Without -s, paste puts several files side by side as columns. The delimiter list is used in turn, so -d',\n' alternates comma and newline.

Further reading: paste manual page

More Terminal tips ioreg -rn AppleSmartBattery | grep CycleCount Terminal can save your windows and tabs as a window group Export a Terminal profile to a .terminal file and import it on another Mac mc hidutil property --set '{"UserKeyMapping":[{"HIDKeyboardModifierMappingSrc":0x700000039,"HIDKeyboardModifierMappingDst":0x700000029}]}' All Terminal tips (116) All topics

Link