Search Results

Search: Posts Made By: donadarsh
2,375
Posted By rdcwayx
Count as zero if 1st column is empty, and don't...
Count as zero if 1st column is empty, and don't count header and trailor.

awk 'BEGIN{FS=OFS="|"} {if ($1=="") {a[$0]=0} else {a[$0]++};b[NR]=$0}
END {print b[1]; for (i=2;i<NR;i++)...
2,375
Posted By aigles
From anchal_khare solution :awk ' BEGIN {...
From anchal_khare solution :awk '
BEGIN { FS=OFS="|" }
NR==1 {
first=$1
}
{
count[$1]++;
last =$1;
key[NR] =$1;
rec[NR] =$0;
}
END {
count[first]--;
...
2,375
Posted By ygemici
# uniq -c infile | sed 's/ *\(.*\)...
# uniq -c infile | sed 's/ *\(.*\) \(.*\)/\2|\1|/'
FHDR|ABC|20100607||1|
|ABC|8453|CDE|E166|||||1|
123|ABC|8453|CDE|E166|||||2|
111|ABC|8453|CDE|E166|||||1|
124|ABC|8453|CDE|E166|||||2|...
2,375
Posted By clx
Not sure how efficient is this, still you can try...
Not sure how efficient is this, still you can try

awk -F "|" '{a[$1]++;b[NR]=$0;c[NR]=$1} END{ for (i=1;i<=FNR;i++) { if (i!=1 && i!=FNR) {print b[i]"|"a[c[i]]"|"} else { print b[i] }}}' file
Showing results 1 to 4 of 4

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