Guest User

Untitled

a guest
Dec 15th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. Dir='/home/TEST'
  4. Project="${Dir}/Project.txt"
  5.  
  6. SOURCE|FILE|TARGET_PATH
  7. TEST|BDL|/LOAN/NDL/XML
  8. TEST|BDL|/LOAN/DL/XML
  9. TEST|BDL|/LOC/DL/XML
  10. TEST|ADU|/LOAN/NDL/XML
  11. TEST|ADU|/LOAN/DL/XML
  12. TEST|ADU|/LOC/DL/XML
  13.  
  14. while IFS='|' read -r source file path
  15. do
  16. unset IFS
  17.  
  18. if [ "${source}!" != "TEST!" ]
  19. then
  20. continue
  21. fi
  22.  
  23. for dir in "${path}"; do
  24. find "${Dir}${dir}" -type f | grep ^'file' >"${Dir}${dir}"/"${file}"_Totallist.txt
  25. echo "${Dir}${dir}"
  26. done
  27.  
  28. done < "$Project"
  29.  
  30. /home/ds4078/TEST_XXX/LOAN/NDL/XML
  31.  
  32. /home/ds4078/TEST_XXX/LOAN/DL/XML
  33.  
  34. /home/ds4078/TEST_XXX/LOC/DL/XML
  35.  
  36. /home/ds4078/TEST_XXX/LOAN/NDL/XML
  37.  
  38. /home/ds4078/TEST_XXX/LOAN/DL/XML
  39.  
  40. /home/ds4078/TEST_XXX/LOC/DL/XML
  41.  
  42. path=`grep "^TEST" ${Dir}/Project.txt | cut -d"|" -f3`
  43.  
  44. for dir in $path; do
  45. for f in `ls -Rd "${Dir}${path}"/* -type f | grep ^${file}`; do
  46. ${f} >"${Dir}${path}"/"${file}"_total_file_list.txt
  47. done
  48. done
  49.  
  50. while read line; do
  51. IFS='|';
  52. fields=($line); # split $line on '|' delimiters
  53. unset IFS;
  54.  
  55. source=${fields[0]}
  56. file=${fields[1]}
  57. path=${fields[2]}
  58.  
  59. if [ "$source!" != "TEST!" ]
  60. then
  61. continue # skip lines not beginning with "TEST"
  62. fi
  63.  
  64. for f in `ls -Rd "${Dir}${path}"/* -type f | grep ^${file}`
  65. do
  66. ${f} >> "${Dir}${path}"/"${file}"_total_file_list.txt
  67. done
  68.  
  69. done <Project.txt
  70.  
  71. for f in "{Dir}${path}"/**/"$file"*; do
  72. if [ -f "${f}" ] # check that $f is a file
  73. then
  74. ${f} >> "${Dir}${path}"/"${file}"_total_file_list.txt
  75. fi
  76. done
  77.  
  78. $ ls *.txt
  79. test1.txt test2.txt test3.txt test4.txt test5.txt
  80.  
  81. $ files=$(ls *.txt)
  82.  
  83. $ echo ${files}
  84. test1.txt test2.txt test3.txt test4.txt test5.txt
  85.  
  86. $ echo "${files}"
  87. test1.txt
  88. test2.txt
  89. test3.txt
  90. test4.txt
  91. test5.txt
  92.  
  93. echo "${path}" | while read dir_path
  94. do
  95. ls -r "${Dir}${dir_path}"
  96. done
  97.  
  98. find path -type f | xargs grep "pattern"
Add Comment
Please, Sign In to add comment