• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

Shell Script Help

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    Shell Script Help

    If this was windows I could knock this out in seconds, but it's linux and I haven't much experience, or more to the point examples that I reverse engineer and rip off

    I have two variables say "name" and "location"

    What I want to be able to to is create a script that will allow me to pick one from each pre-determined list and then use them in a series of file paths to then move them to a single place

    Code:
    Source\%name%\%1%\filename1
    Source\%name%\%2%\filename2
    Source\%name%\%3%\filename3
    
    Source\%location%\%a%\filename2
    Source\%location%\%b%\filename2
    Source\%location%\%c%\filename2
    
    cp source\%var1%\filename1 destination\filename1
    cp source\%var2%\filename2 destination\filename2
    
    ./destination/run.sh
    Firstly does the ask make sense?
    Originally posted by Stevie Wonder Boy
    I can't see any way to do it can you please advise?

    I want my account deleted and all of my information removed, I want to invoke my right to be forgotten.

    #2
    Originally posted by SimonMac View Post
    If this was windows I could knock this out in seconds, but it's linux and I haven't much experience, or more to the point examples that I reverse engineer and rip off

    I have two variables say "name" and "location"

    What I want to be able to to is create a script that will allow me to pick one from each pre-determined list and then use them in a series of file paths to then move them to a single place

    Code:
    Source\%name%\%1%\filename1
    Source\%name%\%2%\filename2
    Source\%name%\%3%\filename3
    
    Source\%location%\%a%\filename2
    Source\%location%\%b%\filename2
    Source\%location%\%c%\filename2
    
    cp source\%var1%\filename1 destination\filename1
    cp source\%var2%\filename2 destination\filename2
    
    ./destination/run.sh
    Firstly does the ask make sense?
    Still need a hand with this? If so PM me.

    Comment


      #3
      Originally posted by bobspud View Post
      Still need a hand with this? If so PM me.
      Yep, will do!
      Originally posted by Stevie Wonder Boy
      I can't see any way to do it can you please advise?

      I want my account deleted and all of my information removed, I want to invoke my right to be forgotten.

      Comment


        #4
        No idea if this is the most elegant way but it seems to work so far

        Code:
        #!/bin/bash
        # Bash Menu Script Example
        
        folder=/home/simonmac
        
        auths=(name1 name2 name3 name4 name5 name6)
        select auth in "${auths[@]}"; do
           cp $folder/auth/$auth/auth.json $folder/AppName/configs/auth.json
           break
        done
        
        configs=(config1 config2 config3)
        select config in "${configs[@]}"; do
            cp $folder/configs/$config/config.json $folder/AppName/configs/config.json
            break
        done
        
        ./AppName/run.sh
        Originally posted by Stevie Wonder Boy
        I can't see any way to do it can you please advise?

        I want my account deleted and all of my information removed, I want to invoke my right to be forgotten.

        Comment

        Working...
        X