How do I read a variable from a file in shell script

Ads
 

How do I read a variable from a file in shell script

Hi,

In my project we are submitting the job on spark cluster through sh file. Now I want to read some of the variables from other file and then use this in spark submit command.

How do I read a variable from a file in shell script and then use it with spark-submit?

Thanks

View Answers

April 18, 2021 at 9:23 AM

HI,

You can define the variable in another file and add the variable definition like:

MYVARIABLE="string value"
DB_IP="192.168.5.7"

Then in the sh file where you are executing spark-submit you can do following:

#!/bin/bash

source <filename>
echo $MYVARIABLE
echo $DB_IP

Hope this helps you.

Thanks

Ads









Related Tutorials/Questions & Answers:
How do I read a variable from a file in shell script
to read some of the variables from other file and then use this in spark submit command. How do I read a variable from a file in shell script and then use...How do I read a variable from a file in shell script  Hi, In my
How do I read a large file quickly in Java?
How do I read a large file quickly in Java?  Hi, I my project I have to read vendor feed which comes in text file. Size of the file is usually in 1-2 GB in size. What is the best way to read the file efficiently? How do I read
Advertisements
How I get a variable from java script to use it in the scriptlet of jsp.
How I get a variable from java script to use it in the scriptlet of jsp.  Hi i want to get the tinyUrl value in the scriptlet of jsp. // Bit.ly API var url="http://cplive.com/dealDetail.do?method=displayDealDetail&
How can i read a file from nth line onwards in java
How can i read a file from nth line onwards in java  Hi, I need to read a file content from its nth line onwards till end. How can i implement it in java. Regards, Chinnu
how to execute a unix shell script from a java program
how to execute a unix shell script from a java program  well , i am... solution . could anyone please give a sample code as of how to do this... what i am... the script name from a java code .once you execute this java program
How to create a .mdf file from script (.sql)
How to create a .mdf file from script (.sql)  Hi, I have a sql database in 2008 server. now i want it to convert to 2005. so i script it. just help me to create a .mdf file back from the script
How do I import a CSV file in R?
How do I import a CSV file in R?  Hi, I have a CSV file with 900000 records and I want to load it for analytics. How do I import a CSV file in R... from data.csv file and uses first row as header. If in your data file you don't
How do I compress a tar file in Linux
How do I compress a tar file in Linux  Hi, I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it. I want to know the tar command
How do I compress a tar file in Linux
How do I compress a tar file in Linux  Hi, I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it. I want to know the tar command
How do I compress a tar file in Linux
How do I compress a tar file in Linux  Hi, I want to create the tar.gz file file of a directory in Linux. My directory contains many sub directories and many files are there inside it. I want to know the tar command
How to read PDF files created from Java thru VB Script
How to read PDF files created from Java thru VB Script  We have created the PDF file thru APache FOP but when we are unable to read the data thru QTP(it's an HP Automation tool). Do u have any addin's to install with QTP
how I do select from select in hql
how I do select from select in hql  select RN from ( select rownum RN, dbid from ( select * from profile p where type = 1912 and name like... doesn't work select RN from ( select rownum RN, DBId from ( select distinct p
How to read and display data from a .properties file from a jsp page
How to read and display data from a .properties file from a jsp page  I have a .properties file. I have to create a jsp page such that it reads the data from this .properties file and display it in table format. Ex:by using
Read Property file From Jmeter
Read Property file From Jmeter  Hi, I am running web driver script from Jmeter, but while reading property file I am getting "File Not Find Exception". Please tell me how to read ".properties" file from Jmeter
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql  how to create a php script to download file from databse mysql
how to create a php script to download file from database mysql
how to create a php script to download file from database mysql  how to create a php script to download file from databse mysql
Read from file java
Read from file java  How to Read from file java? What is the best method for a text file having a size of 10GB. Since i have to process the file one line at a time so tell me the very best method. Thank you
How do I set environment variables from Java?
How do I set environment variables from Java?  How do I set environment variables from Java
How do I install a .deb file via the command line?
How do I install a .deb file via the command line?  How do I install a .deb file via the command line?   Hi, You can install it with following command: sudo dpkg -i DEB_PACKAGE Example: sudo dpkg -i packagename.deb
how read data from doc file in same formate in jsp
how read data from doc file in same formate in jsp  how we can read and display data on jsp page, from doc file with the same formatting
how do i upload a file by using servlet or jsp?
how do i upload a file by using servlet or jsp?  hi plz tell me the write java code
How do I throw a 404 error from within a java servlet?
How do I throw a 404 error from within a java servlet?  How you can write code in Servlet for throwing the httpd error 404? How to add the configuration for handling the not found error in the web.xml file? Thanks   
how do i allow users to download a xls file in html?
how do i allow users to download a xls file in html?  can anyone help me to allow users to download a xls file in html? i tried with href="path...;i tried with href="path/filename.xls click here but it works only in chrome
How do I start learning data science from scratch?
How do I start learning data science from scratch?  Hi, I am... to learn: How do I start learning data science from scratch? Try to provide me good examples or tutorials links so that I can learn the topic "How do
How do I become a data analyst from scratch?
How do I become a data analyst from scratch?  Hi, I am beginner... to learn: How do I become a data analyst from scratch? Try to provide me good examples or tutorials links so that I can learn the topic "How do I become
How do I learn Java programming in one day from zero?
How do I learn Java programming in one day from zero?  Hi, I am.... Is there any way of really learning Java in one day? How do I learn Java programming in one day from zero? I am aware of C and C++ programming language. I have used
How do I learn Java programming in one day from zero?
How do I learn Java programming in one day from zero?  Hi, I am.... Is there any way of really learning Java in one day? How do I learn Java programming in one day from zero? I am aware of C and C++ programming language. I have used
read from cmd syntax and open the file
read from cmd syntax and open the file  i have to read the name of the database e.g., "database.txt" file from a cmd syntax and open it: java FindKeys database=db.txt;minjoinrows=integer|all how can i do
read from cmd syntax and open the file
read from cmd syntax and open the file  i have to read the name of the database e.g., "database.txt" file from a cmd syntax and open it: java FindKeys database=db.txt;minjoinrows=integer|all how can i do
Scala Shell in Spark - How do I run Scala in spark shell?
can type following: :q Above code will exit from spark-shell... will show you how to run the Scala shell that comes with the Apache Spark... spark-shell.cmd can be run from command prompt which brings the Scala shell
Java read lines from file
Java read lines from file  Any code example related to Java read lines from file? In my project there is requirement of reading the file line by line and splitting the command separated data and saving into database. I know how

Ads