Quote:
Originally Posted by satish.res
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
|
Have you tried some of the commands suggested by bartonski? If you try the date command, you will see that the format dd/mm/yyyy is not valid for option -d, --date since it's not a default. Hence you have to arrange items and pass a valid format to the date command.
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 }
{
split($2, array, "/")
datespec = sprintf("%s %s %s 0 0 0",array[3],array[2],array[1])
timestamp = mktime(datespec) - 7 * 86400
print $1, strftime("%d/%m/%y", timestamp)
}
You can try that on the very first lines of the file. I repeat invitation by bartonski. For any doubt related to awk, cut or any other command feel free to ask and please take in mind that the more you ask/explain the more you get a suitable help. Even better if you show us your attempts, codes, desired output.
Welcome to LinuxQuestions!
