U
U
udi2013-11-20 15:26:38
linux
udi, 2013-11-20 15:26:38

How to clone files in Linux?

There is a following task.
The directory contains a file, for example 1.jpg and a text file names.txt with file names in the format

2.jpg
3.jpg
4.jpg
5.jpg
....
100.jpg


You need to clone the file 1.jpg with a linux command as many times as there are lines in the names.txt file , renaming the files according to the contents of each line.
As a result, the directory should have X identical files with different names.

Prompt command or commands, please.
Ubuntu, if anything.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
C
Chromium58, 2013-11-20
@udi

while read line;do cp 1.jpg $line;done< names.txt
How many variations of reading a file, so many implementations can be :)

E
egor_nullptr, 2013-11-20
@egor_nullptr

for i in `cat names.txt`; do cp 1.jpg $i; done

S
seniorivn, 2013-11-20
@seniorivn

It's not comme il faut to help with ready-made solutions in such matters, so:
bash awk grep sed
This is Russian mana for the most popular console utilities / word processors and for the bash scripting language. Go ahead.

R
rich, 2013-11-20
@rich

...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question