Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • 5
    What database engine are you using? What is the format of the input file? If it's CSV, can't you just import the data straight into the table instead of creating SQL to do it? This would also deal with the issues you would otherwise have if any field contains single quotes. Commented Aug 9, 2024 at 5:22
  • I'm also noticing that your scrip definitely does not produce the output that you say it does. Ut would be good if you could ensure that the provided code corresponds with the given output. Commented Aug 9, 2024 at 7:30
  • It's a comma because your outputline echo $"(..., '$LINE', ...)," >> $OUTPUT makes it a comma. Commented Aug 9, 2024 at 13:59
  • @Wastrel I know, right? Commented Aug 9, 2024 at 14:34
  • @JinKwon I don't know much about SQL, but I guess you want only the last line of output to have a semicolon instead of a comma, not all of them. That was my misunderstanding. I wouldn't input the file with cat and read in the first place. I'd make an array, from which I could find the last line and treat it differently. As others suggest, a shell script might not be the best tool for this, but it can be done. Commented Aug 9, 2024 at 15:14