Assume I have three text files, data_1, data_2, and data_3. Firstly, I need to copy data_1 inside to another new text file (new_data). Then I need to add data_2 to new_data (includes data_1). Finally I need to add data_3 to new_data (includes data_1 and data_2).
For example,
data_1= 10 10 10
15 15 15
data_2=5 5 5
data_3= 11 11 11
12 12 12
new_data= 10 10 10
15 15 15
5 5 5
11 11 11
12 12 12
How can I perform this task as a sequential way for multiple text files?
As you are just appending the file contents one after another, use
cat
maintaining the sequence you want, currently this should do:The shell will expand
data_{1..3}
intodata_1 data_2 data_3
, so the operation would eventually be: