I have a file called Year.txt
Year2000= 1/2/3/4/
Year2001= 5/6/7/8/
Year2002= 9/10/11/12/
....
....
....
Year2020= 100/101/102/
etc and so on
I need to take this Year.txt as reference in my another script some sample.sh
sample.sh
source /home/user/Year.txt
d=cp $filename $1
echo $d
sample.sh Year2000(passing Year2000 as first argument)
**I need to cut the second part after = if I pass Year2000 as my argument and paste this 1/2/3/4/ in my statement
**I need to cut the second part after = if I pass Year2001 as my argument and paste this 5/6/7/8/ in my copy statement etc..
I need output like this:
Input1 sample.sh Year2000
Output: cp somefile.txt 1/2/3/4/
Input2: sample.sh Year2001
Output: cp somefile.txt 5/6/7/8/
In Short -- I need to take the reference from another file and generate the copy statement
=? If so, it's not a legal bash assignment, so you can'tsourceit./bin/sh, or can you use bash? (Associative arrays are a very good fit for the problem at hand). Sincesourceisn't a legal POSIX sh statement, it sounds likely you're already testing on bash anyhow.sh; it must be invoked asbashfor the full extended language to be available.