简体   繁体   中英

Declare Variables from a shell script in the shell

Can you guys tell me how to write a shell script which declares for example a variable in the shell like this: var="foobar". It just has to write the exact same thing like I would write it manually in the shell.

appreciate help because this would help me a lot ! I am not so experienced in shell scripting :/

For this, you have to create a script ( file.sh , for example) containing the line:

var="foobar"

and then source the file:

source file.sh

or

. file.sh

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM