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*

7
  • Do I run all these commands in a script file. when i run individual commands , for tail +2 i get tail : cannot open '+2' no such file or directory it prints only 10 lines not complete file Commented Oct 12, 2022 at 6:12
  • I got it worked after giving tail -n +2 sample.csv. after done script exits before executing rm header. do i place it before done Commented Oct 12, 2022 at 7:03
  • 1
    Since you're using text processing tools, you have to make the explicit assumption that records are line-delimited, i.e., that no field contains embedded newlines. If there are embedded newlines, you run the risk of corrupting the data by spitting inside records. Commented Oct 12, 2022 at 7:37
  • 1
    @kumar You use header in every iteration, so you cannot delete the file inside the loop. There is no reason for the script to exit at that point. Maybe run with -x enabled in the script, and watch the debug. Commented Oct 12, 2022 at 8:34
  • 1
    Either with the --additional-suffix param, or change the cat like so cat header "$f" > "${f/temp/test}.csv" Commented Oct 12, 2022 at 12:15