79626928

Date: 2025-05-17 19:42:03
Score: 0.5
Natty:
Report link

Using any awk:

$ awk 'BEGIN{FS=OFS=","} {split($2,a,/ v?|-.*/); print $0, (NR>1 ? a[2] : "simple_"$2)}' input.csv
id,version,simple_version
84544,abcd v2.1.0-something,2.1.0
3439,abcd a82f1a,a82f1a
3,abcd 2.2.1-bar,2.2.1

Using a while-read loop as you have in the question is an anti-pattern, see why-is-using-a-shell-loop-to-process-text-considered-bad-practice and if you want to do any more complicated CSV processing with awk then see What's the most robust way to efficiently parse CSV using awk?.

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-2):
Posted by: Ed Morton