$ sed '/,$/{N;s/\n//;}' file
line-1
line-2
line-3-should-be-a-very-long, line-3-continued
line-4
Если пробелы следует удалить:
$ sed '/,$/{N;s/\n[[:blank:]]*//;}' file
line-1
line-2
line-3-should-be-a-very-long,line-3-continued
line-4
(если вы хотите, чтобы между строками оставался один пробел, замените //
в коде на/ /
)
Если строки можно продолжать несколько раз, как в
line-1
line-2
line-3-should-be-a-very-long,
line-3-continued,
line-3-continued-further
line-4
затем,
$ sed '/,$/{:loop;N;s/\n[[:blank:]]*//;/,$/bloop;}' file
line-1
line-2
line-3-should-be-a-very-long,line-3-continued,line-3-continued-further
line-4
Этот последний sed
скрипт объясняется аннотациями:
/,$/{ # if the current line ends with a comma, then...
:loop # define label "loop"
N # append next line from input (a newline will be inserted in-between)
s/\n[[:blank:]]*// # delete that newline and any blanks (tabs or spaces) directly after it
/,$/bloop # if the line now ends with comma, branch to the "loop" label
}
# implicit output of (possibly) modified line at end
С GNU Parallel это выглядит так:
cat "$output.txt" |
parallel --retries 5 -P 16 -I {} -L 1 curl -u >> response.txt
или:
cat "$output.txt" |
parallel --retries 5 -P 16 curl -u >> response.txt