Horizontally print file contents
To concatenate the contents of a vertical file horizontally in Unix, you can use the paste command with the -s option.
Here’s an example:
Let’s say you have a file file.txt with the following vertical content:
apple
banana
orange
You can concatenate the contents horizontally using the following command:
paste -s file.txt
This will produce the output:
apple banana orange
The -s option tells paste to concatenate the lines horizontally instead of vertically. By default, paste separates the columns with a tab character. If you want to use a different separator, you can specify it with the -d option followed by the separator character. For example:
paste -s -d, file.txt
This will produce the output:
apple,banana,orange
where the comma is used as the separator.
I have aliased it to hcat,
alias hcat="paste -s"