I want to name each .tar file in the code below and name it based on a list-file that contains the names, but I don't want to mess with the exclusion tag. I have a list file and I was thinking of using a text editor and adding cvf to the beginning of each line I have in a list and then use sed to replace the string cvf, thus adding the flag and then the name follows.
i.e.
cvf name1
cvf name2
cvf name3
I tried using sed 's/cvf/word2/g' input.file
and as expected it only replaces cvf with the replacement word. I want the replacement word (word2) to change and to be each line from a list file.
Code I want modified:
stage ('Zip Repo340') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
stage ('Zip Repo341') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
stage ('Zip Repo342') {
steps {
sh"""
tar --exclude='*.tar' -cvf .tar *
"""
I have 340 of these repositories and I want to name them based on a list file that I have.
List file:
name1
name2
name3
Desired output:
stage ('Zip Repo340') {
steps {
sh"""
tar --exclude='*.tar' -cvf name1.tar *
"""
stage ('Zip Repo341') {
steps {
sh"""
tar --exclude='*.tar' -cvf name2.tar *
"""
stage ('Zip Repo342') {
steps {
sh"""
tar --exclude='*.tar' -cvf name3.tar *
"""
I can add cvf to each line of my list file, but if there's a more elegant solution I'm all ears. The biggest issue I'm having is running the sed replacement command and have the replacement word come from a list file.