开发者

repeat string in a line 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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜