Results 1 to 7 of 7

Thread: Convert ascii to binary?

  1. #1
    Join Date
    Nov 2009
    Beans
    626

    Convert ascii to binary?

    .
    Last edited by PDA1; September 18th, 2012 at 02:37 PM.

  2. #2
    Join Date
    Nov 2010
    Location
    /Earth/Asia/India
    Beans
    218
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Convert ascii to binary?


  3. #3
    Join Date
    Nov 2009
    Beans
    626

    Re: Convert ascii to binary?

    .
    Last edited by PDA1; September 18th, 2012 at 02:37 PM.

  4. #4
    Join Date
    Jan 2005
    Location
    South Africa
    Beans
    2,098
    Distro
    Ubuntu 12.04 Precise Pangolin

    Re: Convert ascii to binary?

    xxd ?

    Code:
    wim@wim-desktop:~$ echo "UBUNTU" |xxd -p
    5542554e54550a
    wim@wim-desktop:~$ echo "UBUNTU" |xxd
    0000000: 5542 554e 5455 0a                        UBUNTU.
    wim@wim-desktop:~$ echo "UBUNTU" |xxd -g1
    0000000: 55 42 55 4e 54 55 0a                             UBUNTU.
    wim@wim-desktop:~$ echo "UBUNTU" |xxd -b
    0000000: 01010101 01000010 01010101 01001110 01010100 01010101  UBUNTU
    0000006: 00001010                                               .
    wim@wim-desktop:~$
    If you don't make backups of your important data, your data is obviously not important to you.

  5. #5
    Join Date
    Sep 2010
    Beans
    898

    Re: Convert ascii to binary?

    And you can use the -n option with 'echo' to suppress the linefeed character:

    $ echo -n Ubuntu |xxd -b
    0000000: 01010101 01100010 01110101 01101110 01110100 01110101 Ubuntu

  6. #6
    Join Date
    Jul 2007
    Location
    Poland
    Beans
    4,499
    Distro
    Ubuntu 14.04 Trusty Tahr

    Re: Convert ascii to binary?

    ...or use printf which is 1 char shorter than echo -n!
    if your question is answered, mark the thread as [SOLVED]. Thx.
    To post code or command output, use [code] tags.
    Check your bash script here // BashFAQ // BashPitfalls

  7. #7
    Join Date
    Nov 2009
    Beans
    626

    Re: Convert ascii to binary?

    Excellent!

    Thank you all.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •