JohnnyInno1 JohnnyInno1 - 2 years ago 82
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/


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/ | 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 Source

You simply have to replace the new line with empty string

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

This will print it on a single line


enter image description here

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download