-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandom-scripts.sh
More file actions
40 lines (33 loc) · 1.33 KB
/
Copy pathrandom-scripts.sh
File metadata and controls
40 lines (33 loc) · 1.33 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
#!/bin/bash
#######################################################################
#Replace string in all files (-R)
#-i = inplace
#-g = globally (every occurance)
find <directory> -type f -name '<file extention, e.g. *.less>'| while read -r F
do
cat $F | grep <search string> && sed -i 's/<search string>/<replace string>/g' $F
done
#######################################################################
#substitute all lines without ids with these ids. Used this for liquibase I guess
for date in `cat ids`
do
#find next occurance
line=$(grep -n -m 1 '<column name="date_pattern" value=""/>' generated.xml | cut -f1 -d ':')
#remove line
sed -i "${line}d" generated.xml
#insert the same but with next value from file
sed -i "$((line - 1)) a <column name=\"date_pattern\" value=\"${date}\"/>" generated.xml
done
#######################################################################
#Create file "generated.xml" and repeat some text with next line from file with some list,
#e.g. with list of ids (can be generated there https://www.guidgenerator.com/online-guid-generator.aspx)
rm -f generated.xml
touch generated.xml
for id in `cat ids`
do
echo "<insert tableName=\"table\">
<column name=\"id\" value=\"${id}\"/>" >> generated.xml;
echo ' <column name="example" value=""/>
</insert>
' >> generated.xml
done