Reputation: 484
I have the following words each in a line in a text editor
'about',
'above',
'across',
'after',
'afterwards',
'again',
'against',
'all',
'almost',
'alone',
Can some help me to convert the above content into a single line using a text editor
'about', 'above', 'across', 'after', 'afterwards', 'again', 'against', 'all', 'almost', 'alone',
Upvotes: 3
Views: 30814
Reputation: 6604
You can do this in any of the more advanced text editors that support regular expressions or some form of control characters by simply replacing \n
with a space. It would help to know which text editor you are using, but generally any of them should use the same, or very similar, syntax (YMMV: depending on the OS, some use \n
, others use \r\n
). To take care of any OS differences, you can use the Regular Expression to match EOL: (\r\n|\n|\r)
and replace instances with a space.
-- Edit: I see this was tagged with word
. You can replace ^p
with a space (
) character and it will do what you want.
Upvotes: 0
Reputation: 5766
You could do it in some modern text editors that allow regex find and Replace. In such editors, you can do it using - Click on the Replace button and put \r\n
or \n
, depending on the kind of line ending (CRLF or LF). In the Search Mode section of the dialog, check the Extended radio button (interpret \n
and such). Then replace all occurrences with nothing (empty string)
In Notepad++, you can do it as :
Edit
-> Line Operations
-> Join Lines
I have also found an online tool where you could just paste the text and it would remove all the line breaks . Check to see if this tool helps -> https://www.textfixer.com/tools/remove-line-breaks.php or https://codebeautify.org/remove-line-breaks .You could find many such tools online where you could just paste your text and it will remove all the line breaks for you.
Upvotes: 3
Reputation: 527
Assuming your text is in a file called break.txt
, and the code below is in a file called `break.awk, then the follwing command will work:
awk -f break.awk break.txt > edited.txt
The output will be in output.txt
and your original file will be unchanged.
BEGIN {
line = ""
}
{
line = line " " $1
}
END {
print line
}
Upvotes: 2