awkã§éè¤è¡ãé«éåé¤ããã
awkã§éè¤è¡ãé«éåé¤ããã
è¡ã®éè¤åé¤ã§èª¿ã¹ãã¨ããåºã¦ããã®ããsort & uniqã使ã£ãã³ãã³ãã ã½ã¼ãã¯ãã¡ã¤ã«ã大ãããªãã¨ãå®è¡ã«ããªãæéãããã£ã¦ãã¾ãã¾ããã
ã½ã¼ãããã«é«éå®è¡ã§ããã®ãã次ã®awkã³ãã³ãã
awk '!colname[$1]++{print $1}'
ãããããã¡ã¤ã«ããã£ã¦ãä¸åç®ã®ååãåå¾ãããã¨ãã!colname[$1]ã¯ããã¼ã¿ããã¼ã«ããé£æ³é åã§ãã¤ã³ã¯ãªã¡ã³ããããã
ãã ããã | colname["ãã"] â 0 {print $1} ãã¤ã±ã« ã¾ããã | colname["ãã¤ã±ã«"] â 0 {print $1} ãã¤ã±ã« ã¾ãã | colname["ãã¤ã±ã«"] â 1 ãµããã¼ PC ã | colname["ãµããã¼"] â 0 {print $1} ãµããã¼ ãã¼ãã¼ã | colname["ãµããã¼"] â 1 ã¹ããã¡ã³ PC ã | colname["ã¹ããã¡ã³"] â 0 {print $1} ãµããã¼ ã¾ãã | colname["ãµããã¼"] â 2 ã¹ããã¡ã³ ã¾ãã | colname["ã¹ããã¡ã³"] â 1
æ¡ä»¶ã¨ãã¦!ãã¤ãã¦ããã®ã§ãäºåç®ä»¥éã¯Falseã¨ãªã£ã¦ããã®ãã¼ã¿ãæåã«ç¾ããè¡ã ããåºåããã¨ãããããã½ã¼ãã¯è¦ããªããã
対象ã®åçªå·ãå¤ãããã¨ãã¯ãä¸ã®ã³ãã³ãã®$1ã$2ã¨ã$3ã¨ãã«ããã°ãkã