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*

9
  • 1
    A shell script is pretty much just a sequence of commands. So if you can solve your problem at the command line you can solve it in a shell script by using those same commands. Does this help? Commented Oct 30, 2021 at 19:02
  • 1
    You might be better with a text processing language like perl, awk, or Python - this task is very easy in Python using the pandas lib and this can be used in a script Commented Oct 30, 2021 at 19:06
  • Refine your problem description. Your problem description "V9 is equal to 3" doesn't match any of your example data. This is difficult in bash, but easy in languages designed for text handling, like perl, Python,...But see man cut paste bash. Commented Oct 30, 2021 at 20:11
  • I do know that python is a better language to manipulate a csv, but I would like to learn bash scripting. I have managed to get the result with adding shell commands to this script. Thank you @roaima (: the only part I am missing, is filtering the output based on the column value. The if statement does not work, is it a correct way to try to output only the rows for witch the V9 column value is 3? Commented Oct 31, 2021 at 8:38
  • The script you post is incomplete -- it just ends in mid-air. The line if [$V9 -eg 3]; then is junk: the variable should be double-quoted, it needs spaces either side of each square bracket, the operator for equal is -eq, none of your data is equal to this, and shell does not do real numbers anyway. This cannot be the script you are running. Pass all scripts through shellcheck.net before running. Commented Oct 31, 2021 at 9:03