-
Notifications
You must be signed in to change notification settings - Fork 165
Expand file tree
/
Copy pathupdate-filelist.sh
More file actions
55 lines (42 loc) · 1.92 KB
/
update-filelist.sh
File metadata and controls
55 lines (42 loc) · 1.92 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#!/bin/bash
# create files
echo "Creating Filelist..."
# test posix regex
find . -maxdepth 1 -regextype posix-extended -regex "test" > /dev/null 2>&1
if test "$?" = "0"; then
FORCE_POSIX_REGEX_1=""
FORCE_POSIX_REGEX_2="-regextype posix-extended"
else
FORCE_POSIX_REGEX_1="-E"
FORCE_POSIX_REGEX_2=""
fi
# get filelist
echo " |- generate ${TMP}"
if test "${FOLDERS}" != ""; then
find ${FORCE_POSIX_REGEX_1} $PWD -type f -not -path "*/\.*" ${FORCE_POSIX_REGEX_2} ${IS_EXCLUDE} -regex ".*/("${FOLDERS}")/.*" ${FORCE_POSIX_REGEX_2} -regex ".*\.("${FILE_SUFFIXS}")$" > "${TMP}"
if [[ "${FILE_SUFFIXS}" =~ __EMPTY__ ]]; then
find ${FORCE_POSIX_REGEX_1} $PWD -type f -not -path "*/\.*" ${FORCE_POSIX_REGEX_2} ${IS_EXCLUDE} -regex ".*/("${FOLDERS}")/.*" ${FORCE_POSIX_REGEX_2} |grep -v "\.\w*$" |xargs -i sh -c 'file="{}";type=$(file $file);[[ $type =~ "text" ]] && echo $file' >> "${TMP}"
fi
else
find ${FORCE_POSIX_REGEX_1} $PWD -type f -not -path "*/\.*" ${FORCE_POSIX_REGEX_2} -regex ".*\.("${FILE_SUFFIXS}")$" > "${TMP}"
if [[ "${FILE_SUFFIXS}" =~ __EMPTY__ ]]; then
find ${FORCE_POSIX_REGEX_1} $PWD -type f -not -path "*/\.*" ${FORCE_POSIX_REGEX_2} -regex ".*\.("${FILE_SUFFIXS}")$" |grep -v "\.\w*$" |xargs -i sh -c 'file="{}";type=$(file $file);[[ $type =~ "text" ]] && echo $file' >> "${TMP}"
fi
fi
# DISABLE
# # find $PWD -type f -not -path "*/\.*" > "${TMP}"
# if [ -f "${TMP}" ]; then
# echo " |- filter by gawk ${TMP}"
# gawk -v file_filter=${FILE_FILTER_PATTERN} -v folder_filter=${FOLDER_FILTER_PATTERN} -f "${TOOLS}/gawk/file-filter-${GAWK_SUFFIX}.awk" "${TMP}">"${TMP2}"
# rm "${TMP}"
# fi
# replace old file
if [ -f "${TMP}" ]; then
echo " |- move ${TMP} to ${TARGET}"
mv -f "${TMP}" "${TARGET}"
fi
if [ -f "${TARGET}" ]; then
echo " |- generate ${ID_TARGET}"
gawk -f "${TOOLS}/gawk/null-terminal-files.awk" "${TARGET}">"${ID_TARGET}"
fi
echo " |- done!"