JohnnyInno1 JohnnyInno1 - 7 months ago 9
Bash Question

How to display output on single line?

How would get a something like this for example in git when I do cat /.ssh/id_rsa.pub

ssh-rsa
AAAAB3NzaC1yc2EAAAADAQABAAABAQCvS2bHikv4KsAAPfX6uRovwuZ3YPcx63DnykdBfEejw3/VaDooKVDRYaW6G7rjSub9iug82oD6Kk2n0Txk3CHpNjCDmoKyI1g7HgHjFMFl3q3qsejMhWtHVz176adlaqXRdYZaMnMXON54Khz2V/7Ghg2wMPG+e6NziGxJF3GvrTaiI/TtkehkZH4htkMy1Vr5mE1Vn5BpkacO7Ms8748xaTgfWVt4ssd8cDR5voxClKBVGJEeir5fLVC0HEJv9p6FFkPMV/qpffxGrvdZ4rUxuh/zhVznALsuhc0sSdDueCtcIcOqE2iwijrwi5uw3irdmfdsnkvsdfasd
Johnny@Johnny-PC


Into one line using the cat command that is suppose to print out text in the file in git like so:

ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCvS2bHikv4KsAAPfX6uRovwuZ3YPcx63DnykdBfEejw3/VaDooKVDRYaW6G7rjSub9iug82oD6Kk2n0Txk3CHpNjCDmoKyI1g7HgHjFMFl3q3qsejMhWtHVz176adlaqXRdYZaMnMXON54Khz2V/7Ghg2wMPG+e6NziGxJF3GvrTaiI/TtkehkZH4htkMy1Vr5mE1Vn5BpkacO7Ms8748xaTgfWVt4ssd8cDR5voxClKBVGJEeir5fLVC0HEJv9p6FFkPMV/qpffxGrvdZ4rUxuh/zhVznALsuhc0383290jnfdsafdjasa Johnny@Johnny-PC


EDIT: I have tried using cat ~/.ssh/id_rsa.pub | awk '{print}' ORS=' ' but it still does the same thing.. I get this:

enter image description here

I have also tried using cat somefile | tr -d '\n' but unfortunetely it gives me the same results too:

enter image description here

Answer

You simply have to replace the new line with empty string

cat ~/.ssh/id_rsa.pub | awk '{print}' ORS=' '

This will print it on a single line


Demo

enter image description here

Comments