Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

duplicates.sh 3.1 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
  1. #!/usr/bin/env bash
  2. # Test gmt convert -Td<select> option to skip duplicates
  3. cat << EOF > data.txt
  4. 0 0 4.46031835138 0.275015041826 AAA
  5. 1 1 4.5705316237 2.1778079668 BBB
  6. 1 1 1.92499958767 2.41849793467 BBB
  7. 1 1 3.46806994568 2.69478794313 CCC
  8. 4 4 3.46806994568 2.69478794313 DDD
  9. 5 5 1.45537732935 0.237260430696 DDD
  10. 5 5 0.526774435084 2.63605870895 AAA
  11. 5 7 4.71711448613 4.23872130655 EEE
  12. 8 8 3.46806994568 0.188999134204 AAA
  13. 9 9 3.46806994568 2.69478794313 AAA
  14. EOF
  15. # 1. Eliminate duplicated x-values
  16. gmt convert data.txt -Td0 > result.1
  17. cat << EOF > answer.1
  18. 0 0 4.46031835138 0.275015041826 AAA
  19. 1 1 4.5705316237 2.1778079668 BBB
  20. 4 4 3.46806994568 2.69478794313 DDD
  21. 5 5 1.45537732935 0.237260430696 DDD
  22. 8 8 3.46806994568 0.188999134204 AAA
  23. 9 9 3.46806994568 2.69478794313 AAA
  24. EOF
  25. # 2. Eliminate duplicated x/y-values
  26. gmt convert data.txt -Td0:1 > result.2
  27. cat << EOF > answer.2
  28. 0 0 4.46031835138 0.275015041826 AAA
  29. 1 1 4.5705316237 2.1778079668 BBB
  30. 4 4 3.46806994568 2.69478794313 DDD
  31. 5 5 1.45537732935 0.237260430696 DDD
  32. 5 7 4.71711448613 4.23872130655 EEE
  33. 8 8 3.46806994568 0.188999134204 AAA
  34. 9 9 3.46806994568 2.69478794313 AAA
  35. EOF
  36. # 3. Eliminate repeated z-values
  37. gmt convert data.txt -Td2 > result.3
  38. cat << EOF > answer.3
  39. 0 0 4.46031835138 0.275015041826 AAA
  40. 1 1 4.5705316237 2.1778079668 BBB
  41. 1 1 1.92499958767 2.41849793467 BBB
  42. 1 1 3.46806994568 2.69478794313 CCC
  43. 5 5 1.45537732935 0.237260430696 DDD
  44. 5 5 0.526774435084 2.63605870895 AAA
  45. 5 7 4.71711448613 4.23872130655 EEE
  46. 8 8 3.46806994568 0.188999134204 AAA
  47. EOF
  48. # 4. Eliminate repeated values in cols 2 and 3
  49. gmt convert data.txt -Td2,3 > result.4
  50. cat << EOF > answer.4
  51. 0 0 4.46031835138 0.275015041826 AAA
  52. 1 1 4.5705316237 2.1778079668 BBB
  53. 1 1 1.92499958767 2.41849793467 BBB
  54. 1 1 3.46806994568 2.69478794313 CCC
  55. 5 5 1.45537732935 0.237260430696 DDD
  56. 5 5 0.526774435084 2.63605870895 AAA
  57. 5 7 4.71711448613 4.23872130655 EEE
  58. 8 8 3.46806994568 0.188999134204 AAA
  59. 9 9 3.46806994568 2.69478794313 AAA
  60. EOF
  61. # 5. Eliminate duplicate record solely on the basis of trailing text
  62. gmt convert data.txt -Tdt > result.5
  63. cat << EOF > answer.5
  64. 0 0 4.46031835138 0.275015041826 AAA
  65. 1 1 4.5705316237 2.1778079668 BBB
  66. 1 1 3.46806994568 2.69478794313 CCC
  67. 4 4 3.46806994568 2.69478794313 DDD
  68. 5 5 0.526774435084 2.63605870895 AAA
  69. 5 7 4.71711448613 4.23872130655 EEE
  70. 8 8 3.46806994568 0.188999134204 AAA
  71. EOF
  72. # 6. Eliminate duplicate record defined by col 2 and trailing text
  73. gmt convert data.txt -Td2,t > result.6
  74. cat << EOF > answer.6
  75. 0 0 4.46031835138 0.275015041826 AAA
  76. 1 1 4.5705316237 2.1778079668 BBB
  77. 1 1 1.92499958767 2.41849793467 BBB
  78. 1 1 3.46806994568 2.69478794313 CCC
  79. 4 4 3.46806994568 2.69478794313 DDD
  80. 5 5 1.45537732935 0.237260430696 DDD
  81. 5 5 0.526774435084 2.63605870895 AAA
  82. 5 7 4.71711448613 4.23872130655 EEE
  83. 8 8 3.46806994568 0.188999134204 AAA
  84. EOF
  85. # Look for differences between results and truth
  86. diff result.1 answer.1 --strip-trailing-cr > fail
  87. diff result.2 answer.2 --strip-trailing-cr >> fail
  88. diff result.3 answer.3 --strip-trailing-cr >> fail
  89. diff result.4 answer.4 --strip-trailing-cr >> fail
  90. diff result.5 answer.5 --strip-trailing-cr >> fail
  91. diff result.6 answer.6 --strip-trailing-cr >> fail
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...