bash - Running script existing in another folder -


मेरे पास कम से कम फ़ोल्डर्स में दो स्क्रिप्ट हैं:

  • / folder_aaa / bbb / ddd / 1 .sh
  • /folder_aaa/ccc/eee/2.sh

    मैं 1.sh स्क्रिप्ट से 2.sh स्क्रिप्ट को चलाने के लिए चाहूंगा। मुझे 2.sh स्क्रिप्ट के लिए पथ कैसे लिखना चाहिए?

    1.sh:

      DIR = / .. / .. / ccc / eee / SCRIPT_NAME = "2 .sh "$ {DIR} / $ {SCRIPT_NAME}   

    कोड से ऊपर है (विशेषकर डीआईआर रेफरेंस) ठीक है?

    आप बस ../../& lt; DIRS & gt; का उपयोग नहीं कर सकते क्योंकि .. उस पर निर्भर करते हुए बदल जाएगा आप हैं, यही वही है जो $ PWD है; .. है का उपयोग करते हुए स्क्रिप्ट के बजाय।

    असलीपाथ और डायनाम नाम
      startdir = "$ (का उपयोग करके) dirname "$ (realpath" $ 0 ")") "स्क्रिप्ट =" 2.sh "" $ startdir "/../../"$ स्क्रिप्ट"   

    पूर्ण पथ का उपयोग करना < / h3>

    यदि आपके पास realpath और dirname तक पहुंच नहीं है या उनका उपयोग नहीं करना है: यदि आपको पता है कि 2.sh और 1.sh में कभी परिवर्तन नहीं होगा, तो आपको 2.sh

      "$ HOME" /code/scripts/2.sh    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -