I have a file test.txt which has huge entry a sample of which is below.
Afghanistan Albania Algeria Andorra Angola Antigua and Barbuda Argentina Armenia Australia Austria Azerbaijan The Bahamas Bahrain Bangladesh Barbados Belarus Belgium Belize Benin Bhutan Bolivia Bosnia and Herzegovina Botswana Brazil Brunei Bulgaria Burkina Faso Burundi Cabo Verde Cambodia Cameroon Canada Central African Republic Chad Chile China Colombia Comoros
I can use
cat test.txt | tr '\n' ',' to convert the new line into a comma-separated list.
However, I want the command separate list as a group of 6 each like below.
Afghanistan,Albania,Algeria,Andorra,Angola,Antigua and Barbuda Argentina,Armenia,Australia,Austria,Azerbaijan,The Bahamas Bahrain,Bangladesh,Barbados,Belarus,Belgium,Belize and so on ...
How could I do this in Centos bash shell?