Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing line brakes in a text file

Status
Not open for further replies.

Larshg

Programmer
Mar 1, 2001
187
DK
Hi

I have a text file, with some line brakes, I would like to remove thiese and make a singel line.

ex.
I have a text file that looks like this
>cat /usr/text.txt

line1 test3
line2
test2
>

I need it to go into one line in a variable
something like this

a=`cat /usr/text.txt|<remove line brakes, and replace them with &quot;&quot;>`
>echo $a
line1 test3 line2 test2
>

any help is appreciated.

/Larshg
 
sed -e :a -e '$!N;s/ *\n/ /;ta' myFile.txt

vlad
+----------------------------+
| #include<disclaimer.h> |
+----------------------------+
 
Try something like this:
Code:
a=`tr '\012' ' ' </usr/text.txt`

Hope This Help
PH.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top