date calculation
i have a text file with many columns and rows ,like msisdn date plan etc
i want to get another column by subtracting 7 days from existing column on each row. how can we achieve using linux commands plz help thanks in advance |
A column can be pulled from data using the commands 'cut' or 'awk' depending on the format of the data.
You can subtract 7 days using the '--date' option of the 'date' command: Code:
$ date --date="Sun Dec 20 03:17:58 EST 2009 - 7 days" Code:
date --help |
like this in a file have more than million rows, i want subtract with 7 days on each row and get the output
MSISDN date 322423423 24/12/2009 464566546 14/01/2008 453344343 15/05/2007 |
Quote:
Anyway, since you have more than one million of rows, the date command is not advised (I remember shell programming manuals discouraged the intensive usage of the date command, but maybe this is not valid in recent days). I suggest a little awk code like this Code:
BEGIN { getline; printf "%-9s %-4s\n", $1, $2 } Welcome to LinuxQuestions! :) |
All times are GMT -5. The time now is 04:12 PM. |