-
Notifications
You must be signed in to change notification settings - Fork 1
/
kuttl-insert-test.sh
executable file
·29 lines (26 loc) · 909 Bytes
/
kuttl-insert-test.sh
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
#!/bin/bash
#
# This script inserts a blank space into kuttl test list
# (id's of test cases including and after requested will be increased)
# Check if argument is provided
if [ -z "$1" ]
then
echo "Please provide a number of test case which number should be increased."
exit 1
fi
# Loop through the files in descending order and rename them
for file in $(ls -v -r [0-9][0-9]-* | grep -vE "9[0-9]+-")
do
# Get the number from the beginning of the filename
number=$(echo "$file" | cut -d '-' -f 1)
# Check if the number is greater than or equal to the argument
if [ "$number" -ge "$1" ]
then
# Increase the number by 1 and rename the file
new_number=$(expr "$number" + 1)
new_number_padded=$(printf "%02d" "$new_number")
new_file=$(echo "$file" | sed "s/^$number-/$new_number_padded-/")
echo "$file -> $new_file"
mv "$file" "$new_file"
fi
done