This regexp i use on ubuntu with sed '1p;/^\s/!d;/^\s*id/d'
. It lefts the first line untouched, removes empty lines and all, that don't begin with '{space}' or begin with '{blank}id'. On mac it lefts only the first line. How should regexp looks like on mac?
Example test.csv
id | code | color_code |
-------+------+------------+
11A00B| 15 | 9129102 |
11A00C| 16 | 9129103 |
(2 rows)
id | code | color_code |
-------+------+------------+
11B00B| 25 | 9129152 |
11B00C| 36 | 9129162 |
(2 rows)
id | code | color_code |
-------+------+------------+
11C00B| 22 | 9129107 |
11C00C| 9 | 9129108 |
(2 rows)
After I call sed -i '1p;/^\s/!d;/^\s*id/d' test.csv
on ubuntu
id | code | color_code |
11A00B| 15 | 9129102 |
11A00C| 16 | 9129103 |
11B00B| 25 | 9129152 |
11B00C| 36 | 9129162 |
11C00B| 22 | 9129107 |
11C00C| 9 | 9129108 |
on mac
id | code | color_code |