Search Results

Search: Posts Made By: mtucker6784
2,381
Posted By RudiC
I guess the next question to be: "What about...
I guess the next question to be: "What about single digit days?" Try this:awk -F, -vOFS=, \
'$4 ~ /^.\// {$4 = "0"$4}
$4 ~ /\/.\// {sub (/^[^\/]*\//, "&0", $4)}
1
...
2,381
Posted By Aia
$4 ~ /^.\//{$4="0"$4}1 $4 ~ Looks only for...
$4 ~ /^.\//{$4="0"$4}1
$4 ~ Looks only for records number 4 which is the date part
/^.\// The action is only performed in string with one character followed by / char, that excludes 10/ (two digits...
2,381
Posted By Scott
The secret is here: $4 ~ /^.\/ which...
The secret is here:


$4 ~ /^.\/

which means that field 4 begins (^) with any character (.) (i.e. a number) followed by a slash (escaped) (\/). If field 4 started with two digits, the match...
2,381
Posted By neutronscott
try awk -F, -vOFS=, '$4 ~ /^.\//{$4="0"$4}1'...
try awk -F, -vOFS=, '$4 ~ /^.\//{$4="0"$4}1' input


mute@thedoctor:~$ cat input
one,two,three,1/12/1999,five
one,two,three,10/12/1999,five
mute@thedoctor:~$ awk -F, -vOFS=, '$4 ~...
10,575
Posted By RudiC
awk -F, 'NR==1; #...
awk -F, 'NR==1; # print line #1 as is (pattern is true; print is default action)
NR>1 {Arr[$1","$2]+=$3} # create (or use if exists) array...
10,575
Posted By Jotne
This may change the order of the lines awk -F,...
This may change the order of the lines
awk -F, '{a[$1","$2]+=$3} END {for (i in a) print i","a[i]}'
100,5/20/2013,22
102,7/24/2013,43
101,7/23/2013,26
101,7/21/2013,179

Edit: Hmm, this was...
10,575
Posted By RudiC
Try this: awk -F, 'NR==1; NR>1 {Arr[$1","$2]+=$3}...
Try this: awk -F, 'NR==1; NR>1 {Arr[$1","$2]+=$3} END{for (i in Arr) print i","Arr[i]}' file
ID#,Date,Minutes
100,5/20/2013,22
102,7/24/2013,43
101,7/23/2013,26
101,7/21/2013,179
Showing results 1 to 7 of 7

 
All times are GMT -4. The time now is 04:05 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy