I recently asked a question on the same forum and found a solution for it. Unfortunately, it has to be converted to UNIX. The issue was to merge lines from a csv file. Each line should end with a semi-colon (;) and if it doesn't combine the next line into it until find a semicolon again.
the solution that worked for me was
@echo off
setlocal disableDelayedExpansion
set "ln="
for /f delims^=^ eol^= %%i in (myfile.txt) do (
set "var=%%i"
setlocal enableDelayedExpansion
if "!var:~-1!"==";" (echo !var!>>temp.csv) else (<nul set /p ="!var!">>temp.csv)
endlocal
)
Would it be possible to convert to UNIX script?
Link to the original post is: Merge line with the next line if last character is a semicolon using batch file