cut the variable from the line and use it to find the file and read the content of that file

Hi,

I am working on one script..I am having files in the below format

file 1 (each line is separated with : delimeter)
SPLASH:SPLASH:SVN
CIB/MCH:MCH:SVN

Now I want from file 1 that most left part of the first line will store in one variable...i.e in the below way
a=SPLASH
b=SPLASH
c=SVN

a=CIB/MCH
b=MCH
c=SVN

and there is one folder which is having number of files that will start with the second varible of each line of file1

like TEST is a folder which is having
SPLASH_release.txt
MCH_release.txt

Now I want when second variable store in b like above example I want to use that variable to find that file in TEST folder and will read the content of that file.

these SPLASH_release.txt files always keep single line like SPLASH_11_26_00_RC01

Please help me on this.

Thanks,

Where are you stuck?

--ahamed

I am not able able to understand how I I can find the file with variable

like if variable stores b=SPLASH how I will search the file start with string SPLASH_Release.txt in number of files and read the content of that file

all files would be in TEST folder

SPLASH_Release.txt
MCH_Release.txt
EPRICING_Release.txt

I have tofind the exact filer in that folder with the valuue store in in variable b and read the content of that file.

Please help me.

test_path='/your/test/folder/path'
while IFS=":" read v1 v2 v3
do 
    [ -f "$test_path/${v2}_Release.txt" ] && cat $test_path/${v2}_Release.txt || echo "${v2}_Release.txt not exists"
done< infile

Thanks for your help

I was able to store the value of splash(2nd field) in variable .I want here in single command to search the file with that variable and store the content of that file in the variable..I don't want to create a loop and make another file.

something like that

find / - name 'Metallica*' -exec ls -l {\}\ \;

b=`find / -name core -exec cat '{}'`

find /rohit/TEST/ -name "$b" -print

Please help me on this

---------- Post updated at 06:50 AM ---------- Previous update was at 06:39 AM ----------

Can you verify whether this code will work or not.

LOCATE=`find /rohit/TEST/ -name "$b_Release.txt" -print`
echo $LOCATE
for i in `cat "$LOCATE"`
do echo $i
done

---------- Post updated 10-30-11 at 12:41 AM ---------- Previous update was 10-29-11 at 07:50 AM ----------

Can someone help on the above problem please?

Thanks in advance

What is your ultimate goal? Do you want to display the contents of the file or store it in a variable?

LOCATE=$( find /rohit/TEST/ -name "${b}_Release.txt" )
cat $LOCATE

--ahamed

PS : You have like 45 posts and still not using code tags! Please use code tags for better readability!

Thanks for your help.I will try the code you gave it to me and also take care of your instruction given to me regarding tags

LOCATE=$( find /rohit/TEST/ -name "${b}_Release.txt" )
cat $LOCATE

My ulitmate goal is to use 2nd filed value to search the filein folder and read the content

SPLASH:SPLASH:SVN

In above code second value is SPLASH i will use it to find the file in TEST folder and read the content of that file and store it in variable.But it should be in single command.

Thanks