Shell script variable $1 used with put command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script variable $1 used with put command
# 1  
Old 05-15-2016
Shell script variable $1 used with put command

I have the following script used, i am new to shell scripting. tryign to understand.
in the put $BASE_FOLDER/$base_name holds which path.
What does it mean by $1

second path in put command is it constructing this path: /user/hive/warehouse/stage.db/$1

what is $1 holding in above path.

Code:
base_name=$1
BASE_FOLDER=/user/hive/warehouse/stage.db

hadoop fs -put /stage/data/data/cerner/$base_name* $BASE_FOLDER/$base_name


Thanks lot for the helpful info.
Moderator's Comments:
Mod Comment Please use CODE tags for full line and multi-line sample input, output, and code segments and ICODE tags for partial line sample input, output, and code segments.

Last edited by Don Cragun; 05-15-2016 at 04:13 PM.. Reason: Change ICODE tags to CODE tags and add ICODE tags.
# 2  
Old 05-15-2016
$1 or ${1} refers to the first argument passed to the script when invoked.
If you have an script named myscript.sh and you invoked it as ./myscript.sh /dir1 /dir2, $1 for it will be /dir1 and $2 will be /dir2

In order to answer your question you need to tell us what arguments are passed to it when invoked.

Last edited by Aia; 05-15-2016 at 03:40 PM..
# 3  
Old 05-15-2016
Hello Aia,

Thanks a lot for the helpful response, now making sense and understanding thank you.

from stage_process.sh file has the following:

Code:
PROCESS_DIR=/usr/local/bin/mchhadoop
$PROCESS_DIR/process_stage_file.sh CLINICAL_EVENT.txt


meaning now $1 is CLINICAL_EVENT.txt


process_stage_file.sh file has the following:
Code:
base_name=$1
hadoop fs -put /stage/data/data/cerner/$base_name* $BASE_FOLDER/$base_name


Last edited by Scrutinizer; 05-15-2016 at 04:04 PM.. Reason: icode tags -> code tags
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

sed command not accepting variable in shell script

I am using a shell script in fedora linux. While calling to the shell I am also passing an argument (var1=0.77) like shown below sh gossip.sh var1=0.77 in the shell following command is written (which doesn't work) sed - i -e 's@prob=@prob="$var1";//@g' file.txt Actually i want the... (7 Replies)
Discussion started by: Fakhar Hassan
7 Replies

2. Shell Programming and Scripting

Unable to pass shell script variable to awk command in same shell script

I have a shell script (.sh) and I want to pass a parameter value to the awk command but I am getting exception, please assist. diff=$1$2.diff id=$2 new=new_$diff echo "My id is $1" echo "I want to sync for user account $id" ##awk command I am using is as below cat $diff | awk... (2 Replies)
Discussion started by: Ashunayak
2 Replies

3. Shell Programming and Scripting

Shell script to put delimiter for a no delimiter variable length text file

Hi, I have a No Delimiter variable length text file with following schema - Column Name Data length Firstname 5 Lastname 5 age 3 phoneno1 10 phoneno2 10 phoneno3 10 sample data - ... (16 Replies)
Discussion started by: Gaurav Martha
16 Replies

4. Shell Programming and Scripting

How i can put the result of a command inside a bash variable?

#!/bin/bash #... for i in `ls -c1 /usr/share/applications` do name="cat $i | grep ^Name= | cut -d = -f2" echo $name #... done Now inside name as output is present: while i want only the result of the command. Ideally i would like obtain that information using only bash ... or... (8 Replies)
Discussion started by: alexscript
8 Replies

5. Shell Programming and Scripting

store last command exit status in variable in shell script

Hello All My req is to store the exit status of a command in shell variable I want to check whether the file has header or not The header will contain the string DATA_ACQ_CYC_CNTL_ID So I am running the command head -1 $i | grep DATA_ACQ_CYC_CNTL_ID Now I have to check if... (6 Replies)
Discussion started by: Pratik4891
6 Replies

6. Programming

How to put variable date from SQL Script

Hi Guys, Can someone please help me on adding/inserting a variable to an sql scipt? Basically I want to assign today's date. As shown below.. set head off; set linesize 300; set pagesize 200; spool /opt/oracle/temp/output.txt select value,count(*) as totalcount from pmowner.pinpebasev... (11 Replies)
Discussion started by: pinpe
11 Replies

7. Shell Programming and Scripting

How to put output of one command into a variable

Hi, Let say I have these 3 files (state, list and myscript). I want to be able get the sample output like below when I run myscript. Any one know how to fix the code? TIA. ~~~~~~~~~~~~~~~ > cat /home/state CA > cat /home/list CA 100 50 20 AUS 120 61 10 > cat myscript... (6 Replies)
Discussion started by: joker_789us
6 Replies

8. Shell Programming and Scripting

How to assign the result of a SQL command to more than one variable in shell script.

Hi Friends... Please assist me to assign the result of a SQL query that results two column, to two variables. Pls find the below code that I write for assigning one column to one variable. and please correct if anything wrong.. #! /bin/sh no=' sqlplus -s uname/password@DBname... (4 Replies)
Discussion started by: little_wonder
4 Replies

9. Shell Programming and Scripting

Perl script variable to read shell command

Solaris 10 Korn shell ksh, Hi there, I have figured out to get yesterday's date which is using the below command: TZ=GMT+24; date +%d-%b-%Y to get the format of 30-Sep-2008 and TZ=GMT+24; date +%Y%m%d to get the format of 20080930. I need this two format. In my perl script below I need... (4 Replies)
Discussion started by: bulkbiz
4 Replies

10. Shell Programming and Scripting

how to give a variable to a command in shell script...

hi all... I am executing a comman in a shell script but the command needs a user input of character 'y' as input so it stops in between...may i know is there is any way of giving that character as input in the shell script itself???...thanks in advance.... (6 Replies)
Discussion started by: santy
6 Replies
Login or Register to Ask a Question