Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I convert multi line text into one line?

I'm trying to make a txt file with a generated key into 1 line. example:

<----- key start -----> lkdjasdjskdjaskdjasdkj skdhfjlkdfjlkdsfjsdlfk kldshfjlsdhjfksdhfksdj jdhsfkjsdhfksdjfhskdfh jhdfkjsdhfkjsdhfkjsdhf <----- key stop -----> 

I want it to look like:

lkdjasdjskdjaskdjasdkjskdhfjlkdfjlkdsfjsdlfkkldshfjlsdhjfksdhfksdjjdhsfkjsdhfksdjfhskdfhjhdfkjsdhfkjsdhfkjsdhf 

Notice I also want the lines <----- key start -----> and <----- key stop -----> removed. How can I do this? Would this be done with sed?

like image 224
john Avatar asked May 18 '11 20:05

john


People also ask

How do I change text from multiple lines to single line?

Step 1: Be prepared with the text which you want to convert. Step 2: Copy the text, JSON, String, Pdf or XML (whichever you want to convert). Step 3: Paste the copied content in the space provided. Step 4: Finally click the "convert" option to get the text converted in a single line.


1 Answers

tr -d '\n' < key.txt 

Found on http://linux.dsplabs.com.au/rmnl-remove-new-line-characters-tr-awk-perl-sed-c-cpp-bash-python-xargs-ghc-ghci-haskell-sam-ssam-p65/

like image 108
Luke Avatar answered Sep 21 '22 23:09

Luke