Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
See what's new at GitLab
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
scripts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
clewsy
scripts
Commits
0c99db9f
Commit
0c99db9f
authored
Jun 14, 2020
by
clewsy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved script so that wildcards ('*') are recognised in list file.
parent
b9e0dc10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
bu.sh
bu.sh
+9
-10
No files found.
bu.sh
View file @
0c99db9f
...
...
@@ -153,25 +153,24 @@ else ## Else if argument is not a specific file, assume it is a list of
## 3) Delete content of the line from the first '#'.
if
[
"
${
STRIPPED_LINE
}
"
]
;
then
## If there is anything left of the stripped line.
if
[
"
$(
echo
"
${
STRIPPED_LINE
}
"
|
cut
-b
${#
STRIPPED_LINE
}
)
"
==
" "
]
;
then
## If there is a trailing space left at the end...
STRIPPED_LINE
=
"
$(
echo
"
${
STRIPPED_LINE
}
"
|
cut
--complement
-b
${#
STRIPPED_LINE
}
)
"
;
## Then delete the trailing space.
fi
STRIPPED_LINE
=
"
$(
echo
"
${
STRIPPED_LINE
}
"
|
cut
--complement
-b
${#
STRIPPED_LINE
}
)
"
;
fi
## Then delete the trailing space.
FULL_PATH
=
${
STRIPPED_LINE
/#\~/
$HOME
}
## Expanded variable will be treated as a literal string.
FULL_PATH
=
${
FULL_PATH
/\
$HOME
/
$HOME
}
## These two commands evaluate first "~" and then "$HOME"
## then substitute either for the actual variable $HOME
## Syntax: ${variable/string_match/replacement}
if
[
-e
"
${
FULL_PATH
}
"
]
;
then
## If the stripped and expanded line exists as a file
echo
-e
"Adding:
${
GREEN
}${
FULL_PATH
}${
RESET
}
"
>
${
DEST
}
## Say so and then
echo
"
${
FULL_PATH
}
"
>>
"
${
TEMP_BU_FILE_LIST
}
"
## copy the stripped/expanded line to the temp file.
else
echo
-e
"Failed:
${
RED
}${
FULL_PATH
}${
RESET
}
does not exist and will be skipped"
## Else skip the line.
fi
for
f
in
${
FULL_PATH
}
;
do
## Loop to capture usecase that includes a wildcard '*' in FULL_PATH
if
[
-e
"
${
f
}
"
]
;
then
## If the stripped and expanded line exists as a file
echo
-e
"Adding:
${
GREEN
}${
f
}${
RESET
}
"
>
${
DEST
}
## Say so and then
echo
"
${
f
}
"
>>
"
${
TEMP_BU_FILE_LIST
}
"
## copy the stripped/expanded line to the temp file.
else
echo
-e
"Failed:
${
RED
}${
f
}${
RESET
}
does not exist and will be skipped"
;
fi
## Else skip the line.
done
fi
done
<
"
${
ARGUMENT
}
"
if
[
!
-e
"
${
TEMP_BU_FILE_LIST
}
"
]
;
then
## If the temp list file was not created
echo
-e
"
${
RED
}
Error:
${
RESET
}
The list file did not list any valid files."
## Then it didn't contain any valid files.
echo
-e
"
${
USAGE
}
"
## So print usage and exit.
QUIT
"
${
NO_VALID_FILES
}
"
fi
QUIT
"
${
NO_VALID_FILES
}
"
;
fi
fi
fi
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment