fork(1) download
  1. #!/bin/bash
  2.  
  3. # ideone boilerplate: run in temp dir
  4. t=$(mktemp -d -t ideone.XXXXXXXX) || exit
  5. trap 'rm -rf "$t"' ERR EXIT
  6. cd "$t"
  7.  
  8. cat <<\: >data.csv
  9. ID,Customer_Name,Cust_ADD
  10. 1,A,CBE
  11. 2,B,POL
  12. 3,C,POL
  13. :
  14.  
  15.  
  16. csv_file="data.csv"
  17.  
  18. new_content="This is Loganayaki ,she is trying to append the csv file
  19.  
  20. But she is not able to, she is facing difficulty using shell script
  21.  
  22. she is seeking help to fix this issue, so that she cab complete her task.
  23. she tried few things which is not helping her"
  24.  
  25. # Apply necessary transformations
  26. replacement=${new_content//\"/\"\"}
  27. replacement=${replacement//$'\n'/$'\\\n'}
  28.  
  29. # Replace
  30. sed "2s/^\([^,]*\),/\"\1$replacement\",/" "$csv_file"
Success #stdin #stdout 0.01s 5276KB
stdin
Standard input is empty
stdout
ID,Customer_Name,Cust_ADD
"1This is Loganayaki ,she is trying to append the csv file

But she is not able to, she is facing difficulty using shell script

she is seeking help to fix this issue, so that she cab complete her task.
she tried few things which is not helping her",A,CBE
2,B,POL
3,C,POL