0

I new to the shell script,I have one text file like below

contracts contract_head
invoices invoice_line
invoices invoice_tax

And i have below function where i need to pass the above values as variables into $1,$2 like example

$1=contracts 
$2=contract_head
function view() {


PRODUCT_VIEW_PATH="/home/"${USER}"/testing/deploy/code/subject/entities"

PRODUCT_ENTITY="$1"

ENTITY_NAME="$2"

PRODUCT_VIEW=$(ls -ld ${PRODUCT_VIEW_PATH}/"${PRODUCT_ENTITY}"/cdp-"${PRODUCT_ENTITY}"-modules/"${ENTITY_NAME}")

PRODUCT_VIEW_FOLDER=$(echo "$PRODUCT_VIEW"|rev|awk -v FS='/' '{print $1}'|rev)

SOURCE_PRODUCT_VIEW_PATH="${PRODUCT_VIEW_PATH}/${PRODUCT_ENTITY}/cdp-${PRODUCT_ENTITY}-modules/"

DESTINATION_PRODUCT_VIEW_PATH="/home/"${USER}"/testing/ramu_testing/subject/emea-contracts/entities/${PRODUCT_ENTITY}/emea-contracts-${PRODUCT_ENTITY}-modules/"
}

Can someone help me , How i can read the above text file when there multiple values in my scenario ?

  • _"i need to pass the above values as variables"_ Do you also need to pass `invoices invoice_line` as `$1 $2`? – Fravadona Jul 12 '22 at 08:43
  • No...Like below $1=contracts $2=contract_head $1=invoices $2=invoice_line.....like so this ...so on....based on values present in text file – rakesh ricky Jul 12 '22 at 09:40
  • See also https://stackoverflow.com/questions/673055/correct-bash-and-shell-script-variable-capitalization - you want to avoid upper case for your private variables. – tripleee Jul 12 '22 at 09:45
  • And, [don't use `ls` in scripts.](http://mywiki.wooledge.org/ParsingLs) Generally try http://shellcheck.net/ to diagnose and even automatically fix many beginner problems. – tripleee Jul 12 '22 at 09:47

0 Answers0