output.sh 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. echo "开始执行output脚本"
  2. echo "删除rediskey.txt"
  3. rm -fr /home/it/middle_data/rediskey.txt
  4. echo "删除value.csv"
  5. rm -fr /home/it/middle_data/value.csv
  6. echo "删除result.csv"
  7. rm -fr /home/it/middle_data/result.csv
  8. echo "新建result.csv"
  9. touch /home/it/middle_data/result.csv
  10. echo "删除bad_name_list.txt"
  11. rm -fr /home/it/middle_data/bad_name_list.txt
  12. echo "新建bad_name_list.txt"
  13. touch /home/it/middle_data/bad_name_list.txt
  14. echo "删除good_name_list.txt"
  15. rm -fr /home/it/middle_data/good_name_list.txt
  16. echo "新建good_name_list.txt"
  17. touch /home/it/middle_data/good_name_list.txt
  18. echo "删除filtered_good_name_list.txt"
  19. rm -fr /home/it/middle_data/filtered_good_name_list.txt
  20. echo "新建filtered_good_name_list.txt"
  21. #touch /home/it/middle_data/filtered_good_name_list.txt
  22. echo "删除filtered_valus.csv"
  23. rm -fr /home/it/middle_data/filtered_valus.csv
  24. echo "新建filtered_valus.csv"
  25. touch /home/it/middle_data/filtered_valus.csv
  26. echo "删除pattern.txt"
  27. rm -fr /home/it/middle_data/pattern.txt
  28. cd /home/it/middle_data/
  29. pwd
  30. redis-cli -n 13 keys "*" > /home/it/middle_data/rediskey.txt
  31. echo "导出 key 完成"
  32. echo "开始读取 value"
  33. IFS_old=$IFS
  34. IFS=$'\n'
  35. for line in `cat rediskey.txt`
  36. do
  37. l=`redis-cli -p 6379 -n 13 llen $line`
  38. redis-cli -n 13 lrange $line 0 $l > /home/it/middle_data/x.txt
  39. tr -s "\n" "," < /home/it/middle_data/x.txt >/home/it/middle_data/x1.txt
  40. sed -i '$s/.$//' /home/it/middle_data/x1.txt
  41. val_middle=$(awk -v RS='\0' -F'1' '{print NF-1}' /home/it/middle_data/x1.txt)
  42. if [ $val_middle -ge 5 ]
  43. #if [ $val_middle -ge 4 ]
  44. then
  45. echo $line >> good_name_list.txt
  46. val=$(cat /home/it/middle_data/x1.txt)
  47. echo $val >> value.csv
  48. else
  49. echo $line >> bad_name_list.txt
  50. fi
  51. done
  52. IFS=$IFS_old
  53. redis-cli -n 13 flushdb
  54. echo "output脚本执行完成"