Clean ups
This commit is contained in:
@ -9,7 +9,9 @@ read -r -a SPARSE_ARRAY <<< "$(
|
||||
do
|
||||
if [[ $(( INDEX % 2 )) -eq 0 ]]
|
||||
then
|
||||
for (( i=1; i<=CHAR; i++ )) do printf "%s " "$FILE_ID"
|
||||
for (( i=1; i<=CHAR; i++ ))
|
||||
do
|
||||
printf "%s " "$FILE_ID"
|
||||
done
|
||||
(( FILE_ID++ ))
|
||||
else
|
||||
@ -21,8 +23,8 @@ read -r -a SPARSE_ARRAY <<< "$(
|
||||
(( INDEX++ ))
|
||||
done <<< "$( sed -E 's/(.)/\1\n/g' "$FILE" | grep -v '^$' )"
|
||||
)"
|
||||
printf "%s" "${SPARSE_ARRAY[@]}" | fold -w 100
|
||||
printf "\n"
|
||||
#printf "%s" "${SPARSE_ARRAY[@]}" | fold -w 100
|
||||
#printf "\n"
|
||||
printf "Sparse array len: %s\n" "${#SPARSE_ARRAY[@]}"
|
||||
SHADOW_ARRAY=( "${SPARSE_ARRAY[@]}" )
|
||||
|
||||
@ -86,12 +88,13 @@ do
|
||||
# Space length ok, can proceed
|
||||
if [[ $FILE_SIZE -le $CONT_SPACE ]]
|
||||
then
|
||||
# Move the file to head of contiguous space
|
||||
# Move cursor to head of contiguous space
|
||||
(( k-= CONT_SPACE ))
|
||||
while [[ $FILE_SIZE -gt 0 ]] && \
|
||||
[[ ${SHADOW_ARRAY[k]} -eq -1 ]] && \
|
||||
[[ ${SHADOW_ARRAY[j+FILE_SIZE]} -ne -1 ]]
|
||||
do
|
||||
# Perform copy
|
||||
SHADOW_ARRAY[k]=$ID
|
||||
SHADOW_ARRAY[j+FILE_SIZE]=-1
|
||||
(( k++ ))
|
||||
@ -103,8 +106,9 @@ do
|
||||
continue
|
||||
fi
|
||||
done
|
||||
printf "%s " "${SHADOW_ARRAY[@]}" | fold -w 100 | tee final-result | cat
|
||||
printf "\n"
|
||||
#printf "%s " "${SHADOW_ARRAY[@]}" | fold -w 100 | tee final-result | cat
|
||||
printf "%s " "${SHADOW_ARRAY[@]}" > final-result
|
||||
#printf "\n"
|
||||
|
||||
# Generate checksum for shadow array
|
||||
CHECKSUM=0
|
||||
|
Reference in New Issue
Block a user