Close. Remember, an awk script has the structure …
PATTERN { ACTION }

So you want ‘NR > 1’ to be a pattern, but you have it as an action.

Your code needs to look more like this …

BEGIN { FS = ","; OFS = "," }
NR > 1 { print $1, $2, $3, $4, $5, $6, $7, $8 "chl-a", $9, "ug/l" }

Regards,
- Robert

On Fri, Nov 19, 2021 at 11:26 AM Rich Shepard <[email protected]>
wrote:

> I have data files needing more columns. The first row is the header with
> column names and I want to skip that row. I have not found the proper place
> to put the command to skip the first row.
>
> Here's an example:
> -------------
> #!/usr/bin/gawk
>
> { NR > 1 }
> BEGIN { FS = ","; OFS = "," }
> { print $1, $2, $3, $4, $5, $6, $7, $8 "chl-a", $9, "ug/l" }
> --------------
>
> I've tried putting the NR > 1 line after the BEGIN command it it still
> prints the two strings on the first line. While I can edit those extra
> strings out of the header I'd like to understand how to place the 'skip the
> first line' command.
>
> TIA,
>
> Rich
>
>
>

Reply via email to