Following command is replacing second column with value e in a complete csv file, but what if i want to replace only in first 100 rows.
awk -F, '{$2="e";}1' OFS=, file
Rest of the rows of csv file should be intact..
awk -F, 'NR<101{$2="e";}1' OFS=, file
NR
built-in variable gives you either the total number of records being processed or line number depending on the usage. In the above awk example, NR
variable has line number. When you put the pattern NR<101
the action will become true for first 100 lines. Once it is false, it will default to 1
which will print remaining lines as-is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With