p1 file
1.2G /home/parkmo
0.5M /home/parkmo/tmp
------------------------------------------
Output
1288490188 /home/parkmo
524288 /home/parkmo/tmp
---- the script -----
cat p1 | awk '{ TEXT1=$1; TEXT2=$2;
SEP=substr(TEXT1, length(TEXT1), length(TEXT1));
STR_VALUE=substr(TEXT1, 0, length(TEXT1-1));
# print SEP;
# print STR_VALUE;
if ( SEP == "K" )
{ VALUE=STR_VALUE*1024 }
else if ( SEP == "G")
{ VALUE=STR_VALUE*1024*1024*1024 }
else if ( SEP == "M")
{ VALUE=STR_VALUE*1024*1024 }
else { VALUE=STR_VALUE }
printf("%d %s\n", VALUE, TEXT2) } '
1.2G /home/parkmo
0.5M /home/parkmo/tmp
------------------------------------------
Output
1288490188 /home/parkmo
524288 /home/parkmo/tmp
------------------------------------------
cat p1 | awk '{ TEXT1=$1; TEXT2=$2;
SEP=substr(TEXT1, length(TEXT1), length(TEXT1));
STR_VALUE=substr(TEXT1, 0, length(TEXT1-1));
# print SEP;
# print STR_VALUE;
if ( SEP == "K" )
{ VALUE=STR_VALUE*1024 }
else if ( SEP == "G")
{ VALUE=STR_VALUE*1024*1024*1024 }
else if ( SEP == "M")
{ VALUE=STR_VALUE*1024*1024 }
else { VALUE=STR_VALUE }
printf("%d %s\n", VALUE, TEXT2) } '
Comments
Post a Comment