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.
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.
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:
is more efficiently written as:
or, preferably as:
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):
When run in a directory with file2.txt containing the text you listed above for file2.txt and file1.txt containing:
(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:
Hello.
For a given folder, I want to select any files find $PATH1 -f \( -name "*" but omit any files like pattern name ! -iname "*.jpg" ! -iname "*.xsession*" ..... \) and also omit any subfolder like pattern name -type d \( -name "/etc/gconf/gconf.*" -o -name "*cache*" -o -name "*Cache*" -o... (2 Replies)
Since my last threads were closed on account of spamming, keeping just this one opened!
Hi,
I have the following reports that get generated every 1 hour and this is my requirement:
1. 5 reports get generated every hour with the names
"Report.Dddmmyy.Thhmiss.CTLR"... (5 Replies)
Hi,
I am trying to extract some patterns from a line. The input file is space delimited and i could not use column to get value after "IN" or "OUT" patterns as there could be multiple white spaces before the next digits that i need to print in the output file . I need to print 3 patterns in a... (3 Replies)
I have a script which is migrated from AIX to Linux & now while running it is no able to concatenate string values
The string concatenation step under while loop is not displaying desired result
Please find below the piece of code:
while read EXT_FILE ; do
EXT_FILE=$EXT_FILE.ext.sent
echo... (7 Replies)
Hi Gurus,
I have a file say for ex. file1 which has 3500 lines in it which are different account numbers and another file (file2) which has 230000 lines in it. I want to read all the lines in file1 and delete all those lines from file2 which has that same pattern as in file1. I am not quite... (4 Replies)
How can I do this:
date = 4 -----------> 04
Month= 3-----------> 03
I wish to make a varibale named Var1 which will hold the value of current date and month value as:
2 digits for date.
2 digits for month.
So finally var1 should hold value as 0403 --- MMDD (11 Replies)
Hi,
I want to write a generic shell script, which can concatenate n number of files passed as parameter ;to an output file which is again a parameter
Example
catfl.sh outfl.txt a.txt b.txt c.txt (3 files to be concatenated into a file outfl.txt)
catfl.sh outfl.txt a.txt b.txt(2 files to be... (3 Replies)
my input file contains thousands of lines like below
234A dept of education
9788 dept of commerce
8677 dept of engineering
How do i add a delimeter ':' after FIRST 4 CHARACTERS in a line
234A:dept of education
9788:dept of commerce
8677:dept of engineering (7 Replies)
What is syntax for String concatenation?
I have $1 as directory.
$var is some variable value
'/' String value.
How do I have to concatenate if I have to run utility -
util $1 followed by '/' followed by $var
There is no space between these three. (2 Replies)