adding data in input file if 2nd script output SUCCESS

Hi All,

how can i edit my original data and add more data if my 2nd script outputs SUCESS?

ex.
input file:
1.txt
nik,is,the

1script.sh
if 2ndscript.sh output SUCCESS then i'm going to edit my input file and add data best,pogi..
sample outputdata.
nik,is,the,best,pogi

2ndscript.sh
output is SUCCESS

how am i sopposed to do that? i dont have any idea.T_T

Please advise,
THanks,

if [  `2ndscript.sh|grep SUCCESS |wc -l` -gt 0 ] ; then
  sed -i 's/$/&,best,pogic/' input
fi
1 Like

thank you sir rdcwayx. i'm going to try it. thx..

---------- Post updated at 06:27 PM ---------- Previous update was at 06:15 PM ----------

tank you very much! :slight_smile:

---------- Post updated at 06:31 PM ---------- Previous update was at 06:27 PM ----------

Hi Sir,

may i know what is the meaning of your code?

sed -i 's/$/&,best,pogic/' input

Thanks,

that's sed replace command, "&" used to add chars after each line.