Concatenation of two patterns

Read the lines from the file[file2.txt] and concatenate the lines into single line then
search the string "INPUT=" from the another file[file1.txt] and if "INPUT" is present in that file[file1.txt]
assign the concatenate patterns into "INPUT=" pattern.

example:

file1.txt

<some lines>
INPUT = 
<some lines>

file2.txt

../A/B/sample.c
../A/c/sample1.c
../e/f/sample2.c
../d/B/sample3.c

Output:

INPUT= ../A/B/sample.c ../A/c/sample1.c ../e/f/sample2.c ../d/B/sample3.c

str=`cat file2.txt | tr '\n' ' '`
sed 's/INPUT=/INPUT= \$str/g' file1.txt

try also:

awk -v f2=file2.txt '/INPUT *=/ {printf $0 ; while (getline x < f2) printf " "x ; } 1' file1.txt

I note that you are looking for INPUT= (without a space) in file1.txt and the Output specified INPUT= (without a space), but your sample file1.txt has INPUT = (with a space before and after the equals sign).

Since there aren't any code tags where you show us the Output you want (even after joeyg's edits), it is hard to tell if you're looking for spaces or tabs as separators in the Output line. (From looking at the quoted text above it looks like you have single spaces between lines from file2.txt but several (seven) spaces before the first line's contents.

Due to using single quotes instead of double quotes, I don't think PikK45's proposal is going to do what is wanted and the use of:

str=`cat file2.txt | tr '\n' ' '`

is more efficiently written as:

str=`tr '\n' ' ' < file2.txt`

or, preferably as:

str=$(tr '\n' ' ' < file2.txt)

Due to a small logic error, rdrtx1's proposal will output an additional INPUT= (along with any number of spaces found on the input line before and after the = at the end of the line. And, if there is more than one INPUT= (including zero or more spaces before the = ), only the first line will contain the data accumulated from reading file2.txt. It also makes an unnecessary assumption that a filename found in file2.txt will never contain a percent character (which could also mess up the output produced).

Your statements above require that file2.txt be read before processing file1.txt, but I agree with rdrtx1's proposal in assuming that there is no need to look at file2.txt at all if file1.txt doesn't contain an INPUT= line.

I think the following comes closer to matching your requirements (note that /usr/bin/awk on Solaris systems doesn't support the -v option; so on Solaris systems use /usr/xpg4/bin/awk or nawk instead of just awk ):

awk -v f2=file2.txt '
/INPUT *=/ {
        if(f2c == "")
                while(getline f < f2)
                        f2c = f2c " " f
        printf("%s%s\n", $0, f2c)
        next
}
{       print}' file1.txt

When run in a directory with file2.txt containing the text you listed above for file2.txt and file1.txt containing:

<some lines>
INPUT = 
<some more lines>
INPUT=  
<and some final lines>

(note that the 2nd line in file1.txt has a single space both before and after the equals sign like you had listed above for file1.txt, but the 4th line does not contain any spaces), the awk script above produces the following output:

<some lines>
INPUT =  ../A/B/sample.c ../A/c/sample1.c ../e/f/sample2.c ../d/B/sample3.c
<some more lines>
INPUT= ../A/B/sample.c ../A/c/sample1.c ../e/f/sample2.c ../d/B/sample3.c
<and some final lines>