Duplicate each field in a text file

Hello all,

I am searching for a solution to the following problem:

Given input such as this:

I would like to find a way to output this:

Thanks in advance!

echo 'entry1 entry2 entry3 entry4' |perl -alne 'print  map {$_ x 2} map{$_." "} @F'
entry1 entry1 entry2 entry2 entry3 entry3 entry4 entry4
1 Like
 sed 's/[^ ]*/& &/g' INPUTFILE 
1 Like
echo entry1 entry2 entry3 entry4 |awk '{for(;++i<=NF;)$i=$i FS $i}1'
1 Like

sed 's/[^ ]*/& &/g' INPUTFILE

1 Like