刪除檔案第一行: sed '1d' filename
刪除檔案最後一列: awk '{print $NF}' filename
awk重複資料刪除行的命令:awk '{if (!seen[$0]++) {print $0;}}' filename
比較檔案的兩種方法:
1)comm -3 --nocheck-order file1 file2
2) grep -v -f file1 file2 :輸出file2中有file1中沒有的行
當然還有diff file1 file2
貼一段昨天寫的shell指令碼~
#!/bin/=` +=` -d +=` +=` + /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/same_similiar_log/ haventoday_input=/home/crawler/petabyte/crawllog/news_data/=/home/crawler/petabyte/crawllog/news_data//opt/hadoop/program/bin/hadoop fs - $yesterday_input/ > /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files//opt/hadoop/program/bin/hadoop fs - $today_input/ >> /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/ /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/all_get > /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/ /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/all_get_without_first_line > /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/- --nocheck-order /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/all_input /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/input_done > /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/ -v -f /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/input_done /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/all_input > /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/ /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/today_diff > /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/ /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/all_input /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/== < /home/spamdetect/changxiaojia/workspace/finance/same_similar_news_mining/mid_files/ $inputfile1