Concatenate multiple string

hi All,
Below is the output of my script, I want to put all this in 1 line, but it is not writing in 1 single line even after concatenate it.

File Name
2
Milage 30:29.50
START TIME - 21SEP23:23:22:52
END TIME - 21SEP23:23:31:52
0:39:41.23
Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333

I have tried below code but no luck,

</start>
Name=File Name
count=2
Mileage=Mileage 30:29.50
Time1=START TIME - 21SEP23:23:22:52
Time2=END TIME - 21SEP23:23:31:52
Duration=0:39:41.23
id=Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333


Final="$Name $count $Mileage $Time1 $Time2 $Duration $id"
</end>

Output -

Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333

I am not getting entire string, please suggest.

I want to write the entire output in different file.

@deepu27 , show the actual output of your script (it should be throwning errors)

confirm OS and shell being used

thks

hint : "..."

Please use code tags for your code and data, I did it for this time...

You say you tried below code but I see none... I thought the idea of catenate was you were here trying to merge 2 files, the first with the name of variable you would find in the second...
I don't understand how the output is produced, but since I see no code...
Please also reply at the previous post, and suggest greatly you look at the hint.

OS is "Ubuntu"

script is reading 1 log file, from which I have grepped few key words, and out out is as below after storing all values in some variable,

File Name
2
Milage 30:29.50
START TIME - 21SEP23:23:22:52
END TIME - 21SEP23:23:31:52
0:39:41.23
Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333

Now I want to write all the above content in 1 line in another file.
for that I wrote code,

'Name=File Name'
'count=2'
'Mileage=Mileage 30:29.50'
'Time1=START TIME - 21SEP23:23:22:52'
'Time2=END TIME - 21SEP23:23:31:52'
'Duration=0:39:41.23'
'id=Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333'

'Final="$Name $count $Mileage $Time1 $Time2 $Duration $id" '

'echo "$Final" >> new_log.txt'

output in file is,
Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333

I ask again, show your code .... is there a problem with this request ?

The 'output in file is' does not represent what the input is showning .
If you want help then please , assist in basic requests.

thanks

Below is the script,

'#!/bin/bash'
'#set -x'
'echo "============================================================" >> result.csv'
'echo "============================================================" >> result.csv'
'echo `date` >> result.csv'
'echo "File name , Segment , Real time , START_TIME , END_TIME, Price Demand, PROJECT_ID" >> result.csv'
'for FILE in *.log'
'do'
'        SEGMENT=`cat "$FILE" | grep -i "_seg_" | cut -d"=" -f2 | cut -d")" -f1`'
'        REALTIME=`cat "$FILE" | grep -C 3  "Result summary" | grep -i "real time"`'
'        START_TIME=`cat "$FILE" | grep -B 9 "Price Range" | grep "START TIME"`'
'        END_TIME=`cat "$FILE" | grep -B 9 "Price Range" | grep "END TIME"`'
'        PRICEDEMAND=`cat "$FILE" | grep -i "price Range" | cut -d":" -f2-`'
'        PROJECT_ID2=`grep CASLIBIN "$FILE" | tail -1 | cut -d" " -f8`'
'        echo "$FILE $SEGMENT $REALTIME $START_TIME $END_TIME $PRICEDEMAND $PROJECT_ID2" >> result.csv'
'        echo $FILE'
'        echo $SEGMENT'
'        echo $REALTIME'
'        echo $START_TIME'
'        echo $END_TIME'

ok, having read this 'code', its obvious it has never worked.
give an ACTUAL sample of the input log file to be parsed.

as an aside - is this your code , is it for work / study ?

thks

Code is working but not printing entire line and it is just printing just last variable.
This is for my work.

I beg to differ.

given your alleged input:

File Name
2
Mileage 30:29.50
START TIME - 21SEP23:23:22:52
END TIME - 21SEP23:23:31:52
0:39:41.23
Initial_check1_Project_f91bcd93-21ea-4263-bde4-740268288333

and the first line of your for FILE in ....

SEGMENT=cat "$FILE" | grep -i "_seg_" | cut -d"=" -f2 | cut -d")" -f1
test.log: command not found

so, unless you've mistakenly posted something else ... you code does not / cannot work as is.

something along the following may work - dependant upon input ....

SEGMENT=$(grep -i "_seg_" "$FILE"| cut -d"=" -f2 | cut -d")" -f1)

but your sample data has no matches ....

@deepu27 , are you able to post an actual sample of a logfile being searched ? , if you do, I will post as [potential] working version of your script.

@deepu27,
what happens if you enable the set -x you commented out in your script?
Does this help you with the further troubleshooting?

As your script stands now (most likely improperly formatted in your post) has no chance to produce anything (but errors/warnings)...
I'd suggest to use the proper forum markdown code tags described here to provide what your actual code attempt looks like.

I have added triple-backticks to the beginning and end of your code. Now the backticks in your code are visible. Without the ' ' ticks it can make sense.

This does a concatenation; it is written to the result.csv file.
The following echo's print on separate lines; I guess it is for debugging?
Without seeing a sample log file it is impossible to say more from here.

The issue remains that you grep the input for the texts _seg_, Result summary, Price Range, price Range, CASLIBIN, and none of those pattern texts is present in your input file. So all your variables will remain empty, and thus your output will also be empty.