Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- Dir='/home/TEST'
- Project="${Dir}/Project.txt"
- SOURCE|FILE|TARGET_PATH
- TEST|BDL|/LOAN/NDL/XML
- TEST|BDL|/LOAN/DL/XML
- TEST|BDL|/LOC/DL/XML
- TEST|ADU|/LOAN/NDL/XML
- TEST|ADU|/LOAN/DL/XML
- TEST|ADU|/LOC/DL/XML
- while IFS='|' read -r source file path
- do
- unset IFS
- if [ "${source}!" != "TEST!" ]
- then
- continue
- fi
- for dir in "${path}"; do
- find "${Dir}${dir}" -type f | grep ^'file' >"${Dir}${dir}"/"${file}"_Totallist.txt
- echo "${Dir}${dir}"
- done
- done < "$Project"
- /home/ds4078/TEST_XXX/LOAN/NDL/XML
- /home/ds4078/TEST_XXX/LOAN/DL/XML
- /home/ds4078/TEST_XXX/LOC/DL/XML
- /home/ds4078/TEST_XXX/LOAN/NDL/XML
- /home/ds4078/TEST_XXX/LOAN/DL/XML
- /home/ds4078/TEST_XXX/LOC/DL/XML
- path=`grep "^TEST" ${Dir}/Project.txt | cut -d"|" -f3`
- for dir in $path; do
- for f in `ls -Rd "${Dir}${path}"/* -type f | grep ^${file}`; do
- ${f} >"${Dir}${path}"/"${file}"_total_file_list.txt
- done
- done
- while read line; do
- IFS='|';
- fields=($line); # split $line on '|' delimiters
- unset IFS;
- source=${fields[0]}
- file=${fields[1]}
- path=${fields[2]}
- if [ "$source!" != "TEST!" ]
- then
- continue # skip lines not beginning with "TEST"
- fi
- for f in `ls -Rd "${Dir}${path}"/* -type f | grep ^${file}`
- do
- ${f} >> "${Dir}${path}"/"${file}"_total_file_list.txt
- done
- done <Project.txt
- for f in "{Dir}${path}"/**/"$file"*; do
- if [ -f "${f}" ] # check that $f is a file
- then
- ${f} >> "${Dir}${path}"/"${file}"_total_file_list.txt
- fi
- done
- $ ls *.txt
- test1.txt test2.txt test3.txt test4.txt test5.txt
- $ files=$(ls *.txt)
- $ echo ${files}
- test1.txt test2.txt test3.txt test4.txt test5.txt
- $ echo "${files}"
- test1.txt
- test2.txt
- test3.txt
- test4.txt
- test5.txt
- echo "${path}" | while read dir_path
- do
- ls -r "${Dir}${dir_path}"
- done
- find path -type f | xargs grep "pattern"
Add Comment
Please, Sign In to add comment