Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR SHELL

join rows in one string linux

sed ':a; N; $!ba; s/
//g' input.txt 
#I cameI sawI conquered!

# Let’s understand how it works:

#    :a; – we define a label called a
#    N; – append next line into sed‘s pattern space
#    $!ba; – if the current line is the last line ($), do not (!) jump to the label :a (a)
#    s/
/REPLACEMENT/g – replace all line breaks with the given REPLACEMENT
Source by www.baeldung.com #
 
PREVIOUS NEXT
Tagged: #join #rows #string #linux
ADD COMMENT
Topic
Name
9+8 =