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*

8
  • 2
    The header seems to be missing from the data. Also, why can't you use awk, a very typical and standard UNIX tool? Commented Nov 6, 2020 at 17:20
  • I am practising on shell scripting and I am very beginner. I''ll update the headers. Commented Nov 6, 2020 at 17:24
  • OK. As long as you understand that this is not something you should do with a shell script (it is slow, and very hard for no reason). So, what do you have so far? What have you tried? Which part of this is giving you trouble? Commented Nov 6, 2020 at 17:33
  • 2
    while IFS=, read -r -a fields; do ...; done < file.csv is the key piece of the solution Commented Nov 6, 2020 at 17:46
  • by using -a fields you are passing it as an array to fields? For example $fields[6] will give me the value of the 6th column? Commented Nov 6, 2020 at 18:08