P
P
Printip2021-03-10 18:18:39
linux
Printip, 2021-03-10 18:18:39

How to duplicate the contents of a string?

Content of file1.txt:
1
2
3
4
5
Output.txt should contain:
11
22
33
44
55

what command can duplicate the contents of a string in a string?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Denis Yuriev, 2021-03-10
@Printip

loops, echo and cat in the ass.
one command can replace everythingsed -r 's/(.*)/\1\1/' < ./file1.txt > ./output.txt

$ cat file1.txt
1
2
3
4
5
$ sed -r 's/(.*)/\1\1/' < ./file1.txt 
11
22
33
44
55

X
xotkot, 2021-03-10
@xotkot

awk '{print $0$0}' file1.txt > output.txt

R
roswell, 2021-03-10
@roswell

for s in $(cat file1.txt); do echo "$s$s" >> output.txt; done

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question