I have a text file:
cat test1
ch140/121_------_T_201607061430
ch140/121_------_T_201611070840
ch140/121_------_T_201611071125
ch140/121_------_T_201611071235
I want add to this file line by line this text:
/121_------_T_201607061430
/121_------_T_201611070840
/121_------_T_201611071125
/121_------_T_201611071235
Result must be:
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
I used:
cat test1 | sed -e 's/ch140//' > test2
for a in $(cat test2)
do
????
done
What command can I use for this?
I tried using a sed
command, but it didn't work.
Best Answer
Explanation
s/old/new/
replaceold
withnew
\/121.*
match/121
and whatever comes after it&&
the matched pattern two timesYou can add
tee
or use redirection to save to a new file