Search Results

Search: Posts Made By: pradeep rawat
1
976
Posted By Scott
Hello! In case you forgot to read the forum...
Hello!

In case you forgot to read the forum rules (https://www.unix.com/misc.php?do=cfrules), here is quick copy.



Cheers.

The UNIX and Linux Forums
1,514
Posted By Jotne
This post is nearly the same as you posted here ...
This post is nearly the same as you posted here
https://www.unix.com/shell-programming-scripting/208169-linux-script.html
I guess you can modify the script there to work for you
Why starting a new...
1,514
Posted By pamu
I have modified the script to get your desired...
I have modified the script to get your desired output with "/" in between.:)

$ cat file
id,name,id_2, success/failure
44,RAJ, 33, SUCCESS
40,JEY, 44,FAILURE
44,RAJ, 33, FAILURE
40,JEY,...
1,514
Posted By pamu
Using Scrutinizer's solution from previous post. ...
Using Scrutinizer's solution from previous post.

$ cat file
id,name,id_2, success/failure
44,RAJ, 33, SUCCESS
40,JEY, 44,FAILURE
44,RAJ, 33, FAILURE
40,JEY, 44,FAILURE
40,JEY, 44,FAILURE...
1,723
Posted By Scrutinizer
Alternatively: awk -F, '{A[$1]; B[$2];...
Alternatively:
awk -F, '{A[$1]; B[$2]; C[$1,$2]++} END{for(i in A){p=i; for(j in B)p=p FS j "=" C[i,j]+0; print p}}' file
1,723
Posted By Jotne
Works fine. Try this.echo "2089,success ...
Works fine. Try this.echo "2089,success
2089,failure
2087,failure
2089,success
2087,failure
3011,success
2089,failure
3011,success
2087,failure
3011,success" | awk -F, -v SU="success" -v...
1,723
Posted By Jotne
Can you explain the ?Y[i,SU]:0 in...
Can you explain the ?Y[i,SU]:0 in Y[i,SU]?Y[i,SU]:0?

Edit: Found it.
Print a 0 instead of blank if no hits :)
1,723
Posted By pamu
Try $ cat file 2089,success 2089,failure...
Try

$ cat file
2089,success
2089,failure
2087,failure
2089,success
2087,failure

$ awk -F, -v SU="success" -v FA="failure" '{X[$1]++;Y[$1,$2]++;next}END{for(i in X){print...
1,723
Posted By Jotne
Not exact what you like, but mat help you on you...
Not exact what you like, but mat help you on you way
awk '{arr[$1]++; next} END {for (i in arr) { print i,arr[i] }}' file

gives2089,failure 1
2087,failure 2
2089,success 2
Showing results 1 to 9 of 9

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