Adding variable text to text file by line

sed 's/\/121.*/&&/' test1
ch140/121_------_T_201607061430/121_------_T_201607061430
ch140/121_------_T_201611070840/121_------_T_201611070840
ch140/121_------_T_201611071125/121_------_T_201611071125
ch140/121_------_T_201611071235/121_------_T_201611071235

Explanation

  • s/old/new/ replace old with new
  • \/121.* match /121 and whatever comes after it
  • && the matched pattern two times

You can add tee or use redirection to save to a new file

sed 's/\/121.*/&&/' test1 | tee test2

The paste command does what cat does but side by side. The -d '' is for paste to use an empty delimiter, so there's nothing between the strings.

$ paste -d '' test1 test2 
ch140/121_------_T_201607061430/121_------_T_201607061430
ch140/121_------_T_201611070840/121_------_T_201611070840
ch140/121_------_T_201611071125/121_------_T_201611071125
ch140/121_------_T_201611071235/121_------_T_201611071235

Should the files be of unequal lenght, you might want to take a look at this question to prevent unsightly results.