Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. awk '$3 ~ /:0$/{print $4-1;next}{print $4}' test.txt
  2. -0.238
  3. 0.754
  4. 0.848
  5. 0
  6. 0.851
  7.  
  8. awk '{if(substr($3,3)==0){$4=$4-1}else{$4=$4}}1' file
  9.  
  10. sdlcb@Goofy-Gen:~/AMD/SO$ cat file
  11. 1 1:? 1:0 0.762
  12. 2 1:? 2:1 0.754
  13. 3 1:? 2:1 0.848
  14. 4 1:? 1:0 1
  15. 5 1:? 2:1 0.851
  16. sdlcb@Goofy-Gen:~/AMD/SO$ awk '{if(substr($3,3)==0){$4=$4-1}else{$4=$4}}1' file
  17. 1 1:? 1:0 -0.238
  18. 2 1:? 2:1 0.754
  19. 3 1:? 2:1 0.848
  20. 4 1:? 1:0 0
  21. 5 1:? 2:1 0.851
  22.  
  23. $ awk '{split($3,a,":");if(a[2]==0){$4=$4-1}}1' file | column -t
  24. 1 1:? 1:0 -0.238
  25. 2 1:? 2:1 0.754
  26. 3 1:? 2:1 0.848
  27. 4 1:? 1:0 0
  28. 5 1:? 2:1 0.851
  29.  
  30. awk 'split($3,a,":"){print a[2]?$4-1:$4}' file
  31.  
  32. awk 'split($3,a,":"){$4=a[2]?$4-1:$4}' file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement