awk - Command to replace specific column of csv file for first 100 rows -
following command replacing second column value e in complete csv file, if want replace in first 100 rows.
awk -f, '{$2="e";}1' ofs=, file
rest of rows of csv file should intact..
awk -f, 'nr<101{$2="e";}1' ofs=, file
nr
built-in variable gives either total number of records being processed or line number depending on usage. in above awk example, nr
variable has line number. when put pattern nr<101
action become true first 100 lines. once false, default 1
print remaining lines as-is.
Comments
Post a Comment