Reputation: 12190
I have a bash script that runs a backup job and produce a csv file.
90927597|1356976813998|90927598
How can I increment / change the value of the 3rd column of my CSV file? ( I actually just want to make it uniq using a random value).
How can I get that done?
Thank you
Upvotes: 1
Views: 2485
Reputation: 289725
Given the file a
, sed 's/hello/bye/g a' replaces all ocurrencies of
hellowith
byein the file
a`.
$ cat a
90927597|1356976813998|90927598
$ sed 's/90927598/hello/g' a
90927597|1356976813998|hello
$
$ sed -i 's/90927598/hello/g' a
$ cat a
90927597|1356976813998|hello
that is, sed -i
replaces the file. Without -i
it shows the replacement on stdout.
each value in the third column with different value for each row, do you think its possible? just random, or use the same value + random value, the idea just to make it uniq
$ awk -v v=YOUR_SEED 'BEGIN {FS = "|"; OFS="|" } $3=++v' a > output_file
(idea got from jthill comment)
Upvotes: 2