Score:0

Reference all paths in single linux script - like a header file for better portability

br flag

Shell Scripting newbie here.

Please bear with me.

Linux 3.0.101-108.87-default x86_64

I have Script1.sh which is referencing folders . I am trying to include all these paths in the script in a single headerscript.sh and then reference the headerscript.sh in Script1.sh

I am doing this right now

Script1.sh
 
setenv SCRIPT  /../site/SCRIPTS
setenv TOP     /../site/TOP
setenv SUB1    /../site/../.../SUB1
setenv SUB2    /../site/../.../SUB2
setenv SUB3    /../site/../.../SUB3
setenv SUB4    /../site/../.../SUB4
setenv SUB5    /../site/../.../SUB5

Instead I want to do something like this

Script1.sh 

include headerscript.sh

and headerscript.sh will look something like this

headerscript.sh

setenv SCRIPT  /../site/SCRIPTS
setenv TOP     /../site/TOP
setenv SUB1    /../site/../.../SUB1
setenv SUB2    /../site/../.../SUB2
setenv SUB3    /../site/../.../SUB3
setenv SUB4    /../site/../.../SUB4
setenv SUB5    /../site/../.../SUB5

This allows me to make the script modular by just including headerscript.sh in another script and easier to debug.

What should I be doing ?

I don't want to include this in .alias

Displayname avatar
br flag
Updated - thanks for correction
guiverc avatar
cn flag
You didn't mention your OS & release, however given the oldest *supported* kernel for on-topic systems here is currently 4.15, your system appears very old (3.0 was from a 2011 based system, a decade old) so I hope your system is off-line.
vn flag
Do you mean to [include one file from another](https://stackoverflow.com/a/192305/4970442)?
Displayname avatar
br flag
Script Works as intended. Thank you so much :)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.