remove new line char

i have a file with a list of hostnames - each host on a new line. I tried to remove them unsuccessfully with sed. Any help would be greatly appreciated .

sed 's/\n//' <filein >fileout.

I also tried it in vi with %s/Ctrlv backspace//g but that didn't work either
lolaferrariAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
woolmilkporcConnect With a Mentor Commented:
echo $(cat filein) > fileout
0
 
medveddCommented:
If you want to remove all new lines, this command will do:

tr -d '\012' <filein >fileout
0
 
medveddCommented:
You probably need to separate hostnames with spaces, this is better way to do it:

sed -e :a -e N -e 's/\n/ /' -e ta <filein >fileout
0
 
woolmilkporcCommented:
a bit shorter, avoiding "cat", so it's purely using shell builtins:

echo $(<filein) > fileout
0
All Courses

From novice to tech pro — start learning today.