I would like to repeat each line's content of a file, any quick solution using sed.
supposed the input file is
abc
def
123
The expected ouput is:
abcabc
defdef
123123
sed 's \(.*\) \1\1 ' infile
This might work for you:
echo -e 'aaA\nbbB\nccC' | sed 's/.*/&&/'
aaAaaA
bbBbbB
ccCccC
sed 'h;G;s/\n//' file.txt
It's even simpler if you take advantage of the variable \0
, which holds the string that was matched:
sed 's/.*/\0\0/'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With