Use of sed

what is the significance of each attribute below in two lines

sed -e 's/.*\(201[8-9][0-9]\{4\}\).*/\1/g'
sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/ /g'`  

1st line - what I have understood is it's purpose is to replace file name with YYYYMMDD for year 2018 & 2019 for 1 st occurance. Is this correct?

2nd line it is removing any new line found

It would be really helpful if someone share link

Partly. Nobody is talking of a "file name". sed reads stdin line by line, and in each line ALL characters except one (for my sed : the last) string matching the RE are deleted. The g flag is meaningless here, as any additional possible match will have disappeared after the first substitute operation. So you will end up with a sequence of lines consisting of bare dates (if exist in the line) or unmodified lines.

Not quite. The trailing back tick is redundant resp. an error. The script in a loop sucks in all lines of a file, then replaces all newlines with single space chars, finally printing one long line with the entire contents of the file.