mysql命令去重 Linux 常用查詢過濾命令

2021-10-14 08:39:48 字數 2816 閱讀 6371

-b :以位元組為單位進行分割。

-c :以字元為單位進行分割。

-d :自定義分隔符,預設為製表符。

-f :與-d一起使用,指定顯示哪個區域。field 字段

eg: $ who

root     pts/0        2020-03-12 21:00 (124.114.237.101)

root     pts/1        2020-03-12 21:18 (124.114.237.101)

$ who | cut -d '/' -f 1               $ who | cut -d ':' -f 2

root     pts                        00 (124.114.237.101)

root     pts                        18 (124.114.237.101)

-q :隱藏檔名。

-v :顯示檔名。

-c :顯示位元組數。

-n :顯示的行數。

head 檔名  --預設顯示十行

eg:$ head -n 4 lampp.sh                    $ head -n 2 -v lampp.sh

#!/bin/bash                         ==> lamp.sh <==

#安裝php                               #!/bin/bash

error_log=/home/error.log              #安裝php

package_path=/home/package

-n 依照數值的大小排序。

-u 意味著是唯一的(unique),輸出的結果是去完重了的。

-r 以相反的順序來排序。

linux uniq 命令用於檢查及刪除文字檔案中重複出現的行列,一般與 sort 命令結合使用。

-c或--count 在每列旁邊顯示該行重複出現的次數。

sort testfile1 | uniq -c

linux tr 命令用於轉換或刪除檔案中的字元。

-d 刪除指定字元

-s 去除多餘的

1、將檔案testfile中的小寫字母全部轉換成大寫字母

cat testfile |tr a-z a-z 

2、刪除多餘的空行

cat last.txt | tr -s '\n'

3、刪除指定的字元

cat last.txt | tr -d '[0-9].'

4、字串去重

cat last.txt | tr -s '[a-za-z]'

-mtime +30    #30天以前修改  

-type d       # d資料夾   f  file

-size +30k    # 大於30k

-perm 755     # 執行許可權為755

find . type f -exec chmod -r 644 {} \;                             # 給當前資料夾所有檔案賦予644

find /home -name "test.txt" -type d -mtime +30                      #查詢三十天以前的目錄

find /home -name "test.txt" -type d -mtime +30 | xargs rm -rf {}\;    #查詢並刪除

find /home -name "test.txt" -type d -mtime -1 -exec cp -r {} /tmp \;  #查詢最近一天並拷貝到tmp下

find /home -name "*.gz" -type d -mtime +10 -exec rm -rf {} \;

-n            #行號

--color       #高亮 匹配到的

-v            #取反

grep "#" -v ./httpd-vhost.conf     #查詢除了#以外的行

grep "#" -v ./httpd-vhost.conf | grep -v "^$"    #查詢除了#意外的行,並將所有空行去掉

grep -n --color "mysql" /etc/passed   # 26:mysql:x:996:994::/home/mysql:/bin/bash

grep -n --color "^mysql" /etc/passed  #以mysql開頭

grep -n --color "nologin$" /etc/passed  #以nologin結尾

-f:    #將:格式化

awk文字編輯神器

awk '' /etc/passed     # 列印第一列  以空格分隔

awk -f: '' /etc/passwd | head 5   #列印第一列 root  將:格式化

awk -f: '' /etc/passwd   # mysql 111 996

ifconfig | grep broadcast | awk '' | awk -f. ''  #查詢ip

mysql去重欄位 mysql多字段去重,並計數

問 題 mysql版本5.5.42 有兩個表,表結構與資料如下 1 goods表 create table goods id int 10 unsigned not null,product varchar 180 collate utf8mb4 unicode ci not null,size v...

mysql 去重方式

distinct group by 不能與order by一起使用,細節看執行計畫 exists 某些地方推薦,資料越多越好用 對下面這條語句去重,查詢資料多時優化,資料多不推薦 select 1 from a r a left join t a m b on a.id b.pid left joi...

mysql 查詢 去重

insert into material id file url select id,ekm.file url from extmaterial as ekm left join select file url from material where id id as pm on pm.file u...