Sponsored Content
Top Forums UNIX for Beginners Questions & Answers How to define multiple environment variables in a shell script? Post 303045861 by sravani25 on Thursday 16th of April 2020 06:26:49 AM
Old 04-16-2020
How to define multiple environment variables in a shell script?

Hi All,
I am running a shell script on centos 7 to get some variable values and want to declare them as environment variables so that i will use them in another shell script.

I am using below script i am able to define one environment variable but it's not allowing me to do for another variable.

Can someone please help me on this issue.

Code:
 path=$(find $config_path -name abc.txt 2>/dev/null )

domain_path=$(cat $path |grep "domain location" )
 
boot=$(find $config_path -name boot.properties 2>/dev/null |head -1 )

 user_name=$(cat $boot |grep username)
echo 'export NAME=$user_name' >> ~/.profile

  passwd=$(cat $boot |grep password)
  echo $passwd
  echo 'export TEST=$passwd' >> ~/.bash_profile

 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

shell script help: sorting, incrementing environment variables and stuff

First: me == noob. Whats a good resource for shell script info cause I'm having trouble finding good info. I'm writing a shell script to automate the setup of a flash 'page flip'. My current code is below. the page flip takes an xml file of format <content> <pages... (1 Reply)
Discussion started by: secoif
1 Replies

2. Shell Programming and Scripting

problem accessing Multiple Variables from C Program to a Shell script

program name--test #!/bin/bash output1=`/home/user/a.c` output2=`/home/user/a.c` k=`$output1 + 1` m=`$output2 + 1` echo $k echo $m --------------------------------------------------------------------------- prgram name--a.c #include<stdio.h> int main() (1 Reply)
Discussion started by: sameworld1980
1 Replies

3. Emergency UNIX and Linux Support

Problem setting environment variables from script

Hi all! I know that environment variables can be set on the .bashrc file, but I need to set them from a sh script. I saw a lot of websites that teach this but it doesn't work for me. #!/bin/sh DEKTOP=$DESKTOP=:/home/rrodrigues/Desktop export DESKTOP if I do echo $DESKTOP returns me... (10 Replies)
Discussion started by: ruben.rodrigues
10 Replies

4. UNIX for Dummies Questions & Answers

Define variables with UNIX script

oopps! I Meant "Define Variables within a UNIX Script" What would be the best way to define a variable in a unix shell script so anyone who views this script doesn't know what value is assigned to that variable. some other location... a="/usr/lib/fileA" Unix script... sed... (5 Replies)
Discussion started by: macastor
5 Replies

5. Shell Programming and Scripting

environment variables in a sed script file

Hello Everyone I need to create a script file which must append some lines to a target text file, I'm using sed for windows, the script file look like this: { a\ STRINGTABLE DISCARDABLE\ BEGIN\ 5, 150 {a\ #define RC_SHELL, "%ID_SHELL%"\ #define RC_NAME, "%ID_NAME%"\ END } ... (1 Reply)
Discussion started by: edgarvm
1 Replies

6. Shell Programming and Scripting

Using Datastage environment variables in Unix script

Hi All, I am using ETL tool Datastage and is installed on Linux environment. Few environment variables are set in datastage. Now my requirement is to use those environment variables in a unix script. Is there any option I can do it? Sugeestions from people working on datastage and linux... (1 Reply)
Discussion started by: bghosh
1 Replies

7. Shell Programming and Scripting

Using a script to define variables and run multiple other scripts in succession.

I'm pretty new to scripting in Korn shell so please forgive me... What I'm trying to do is to create a script that calls multiple other ksh scripts and defines variables for text files. I need it to define my user defined variables (file paths, date & time stamps, etc that are currently in... (1 Reply)
Discussion started by: bluejwxn8
1 Replies

8. Shell Programming and Scripting

Sourcing .cshrc (C shell) environment variables to bash

I have tried with the following: csh -c 'source ~/.cshrc; exec bash' # works perfectly (cat ~/.cshrc; echo exec bash) | csh # not working And, using sed, I successfully retrieved the environment variables from ~/.cshrc sed -rn 's/setenv\s+(\S+)\s+(.*)$/export \1=\2/p' ~/.cshrc but now... (6 Replies)
Discussion started by: royalibrahim
6 Replies

9. Linux

How to store count of multiple queries in variables in a shell script?

how to store the count of queries in variables inside a filein shell script my output : filename ------- variable1=result from 1st query variable2=result from 2nd query . . . . (3 Replies)
Discussion started by: sanvel
3 Replies

10. Shell Programming and Scripting

How to define two digits variable in shell script?

Dear Shell script Experts, I am working on shell script which is defined here, qsub_seq.csh . The purpose of this script is to read few input files (with defined starting index and last index) and make processing faster over server. For some task, I had 1064 of input files, so I wrote another... (8 Replies)
Discussion started by: emily
8 Replies
HIER(7) 						 Miscellaneous Information Manual						   HIER(7)

NAME
hier - file system hierarchy DESCRIPTION
A tour through the Minix directory hierarchy. / root /bin/ Utility programs, cf /usr/bin/ (1) cat Show files, cat(1) sh Shell, sh(1) mount Mount file systems, mount(8) ... /boot Boot Monitor, monitor(8) /dev/ devices (4) console Main console, tty(4) tty* Terminals, tty(4) hd* Hard disk, hd(4) fd* Floppy disk, fd(4) ... /etc/ System configuration and data files, cf /usr/etc/ (1,5,8) ethers Ethernet addresses database, ethers(5) fstab File system table, fstab(5) group Groups database, group(5) hostname.file Name of the local system, usage(5) hosts TCP/IP hosts database, hosts(5) hosts.equiv Network equivalent hosts, hosts.equiv(5) keymap Keymap for custom keyboard, loadkeys(8) motd Message of the day, login(1) mtab Mounted file system table, fstab(5) passwd User database, passwd(5) psdatabase Kernel info for ps command, ps(1) profile System wide shell profile, sh(1) rc System startup script, boot(8) resolv.conf TCP/IP domain name system, resolv.conf(5) services TCP/IP names to services, services(5) shadow Shadow password database, passwd(5) termcap Terminal type descriptions, termcap(5) ttys Active terminals, init(8) ttytype Terminal types, login(1) utmp User login database, login(1) ... /minix Minix kernel image, monitor(8) /tmp/ Small, short-lived temporary files, cf /usr/tmp/ /usr/ Home directories and more system files adm/ System administration files (1,5,8) wtmp User logins and logouts, login(1) ... ast/ Honorary home directory of Andrew S. Tanenbaum Also new user initial files user/ Home directory of user .ashrc Ash (shell) startup, ash(1) .ellepro.b1 Elle (editor) startup (compiled), elle(1) .ellepro.e Elle (editor) startup (text), elle(1) .exrc Ex/vi (editor) startup, ex(1) .profile Custom user shell profile, sh(1) .rhosts Remote user permission file, rhosts(5) ... bin/ User programs cc C compiler, cc(1) cp Copy files, cp(1) ls List files, ls(1) man Show manual pages, man(1) ... etc/ More system data files, cf /etc (8) ... include/ C-compiler include files minix/ Minix kernel include files ... ... lib/ Compiler libraries and other support stuff cawf/ Text formatter support files, cawf(1) crontab Cron jobs, cron(8) dict/ Word lists words American English word list, look(1) ... libc.a C library (Minix-8086 only), cc(1) arch Per architecture compiler binaries and libaries, cc(1) ... local/ Local software, cf /usr/ bin/ Local utilities man/ Local manual pages src/ Local sources ... man/ Manual pages, man(1) cat*/ Preformatted manual pages man0/ Section 0, Book style user commands man1/ User commands man2/ System calls man3/ Library routines man4/ Device files man5/ File formats man6/ Games man7/ Miscellaneous man8/ System utilities whatis Table of manual pages, whatis(5) ... mdec/ boot Bootstrap code, installboot(8) ... preserve/ Saved elvis editor buffers, elvprsv(8), elvrec(1) spool/ Mail and command spooling at/ At jobs, at(1) past/ Completed at jobs mail/ Mail drops, mail(1) user Mailbox of user ... ... src/ System and command sources (home of bin) LICENSE Minix license to use commands/ Utility sources crclist CRC checksums of the source tree, srccrc(8) lib/ Library sources fs/ File system inet/ TCP/IP task kernel/ Kernel mm/ Memory manager boot/ Boot Monitor tools/ Kernel image making tools, tools(8) tmp/ Large temporary files SEE ALSO
ls(1), man(1), find(1), grep(1), checkhier(8). NOTES
Not all of the directories and files shown are present. They must be created as needed. BUGS
Many of the listed manual references do not yet exist. AUTHOR
Kees J. Bot (kjb@cs.vu.nl) HIER(7)
All times are GMT -4. The time now is 06:56 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy