Repeat line in line with sed

I would like to iterate over every line content in a file, any quick solution using sed.

it is assumed that the input file

abc
def
123

Expected output:

abcabc
defdef
123123

+3


a source to share


5 answers


sed  \(.*\) \1\1 ' infile

      



+6


a source


sed 'h;G;s/\n//' file.txt

      



+1


a source


This might work for you:

echo -e 'aaA\nbbB\nccC' | sed 's/.*/&&/'
aaAaaA
bbBbbB
ccCccC

      

+1


a source


It's even easier if you use a variable \0

that contains the string that was matched:

sed 's/.*/\0\0/'

+1


a source


try it

awk '{print $0$0}' temp.txt

0


a source







All Articles