开发者

repeat string in a line using sed

开发者 https://www.devze.com 2022-12-30 11:32 出处:网络
I w开发者_开发知识库ould like to repeat each line\'s content of a file, any quick solution using sed.

I w开发者_开发知识库ould 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/'


Try this

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

0

精彩评论

暂无评论...
验证码 换一张
取 消