LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-16-2011, 06:16 PM   #1
peterson.julia
Member
 
Registered: Nov 2009
Distribution: All flavors...
Posts: 37

Rep: Reputation: 1
How to convert binary number to text/ascii?


Hi,
is there command in linux which is able to convert binary (0101001010000100) to text like it means something?

Thx
 
Old 03-16-2011, 06:41 PM   #2
pljvaldez
LQ Guru
 
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 271Reputation: 271Reputation: 271
bc ibase=2 0101001010000100 should do the trick.

EDIT: I found another article that says you need to use echo and pipe to bc like this
Code:
echo 'ibase=2;obase=A;0101001010000100' | bc
EDIT2: If you want to use wcalc, just do
Code:
wcalc 0b0101001010000100
The "0b" at the beginning means it is a binary input.

Last edited by pljvaldez; 03-16-2011 at 06:49 PM.
 
Old 03-16-2011, 06:57 PM   #3
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
I noticed those examples convert over, but not to the actual ASCII characters; ie 01110100011001010111001101110100 to test. Is there anyway to do that?
 
Old 03-16-2011, 11:38 PM   #4
peterson.julia
Member
 
Registered: Nov 2009
Distribution: All flavors...
Posts: 37

Original Poster
Rep: Reputation: 1
Quote:
Originally Posted by corp769 View Post
I noticed those examples convert over, but not to the actual ASCII characters; ie 01110100011001010111001101110100 to test. Is there anyway to do that?
Exactly to convert ti to actual ASCII...
 
Old 03-16-2011, 11:45 PM   #5
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 333

Rep: Reputation: 141Reputation: 141
Try
Code:
bin='01110100011001010111001101110100'
printf $(echo "obase=16;ibase=2;$bin" | bc | sed 's/../\\x&/g')

test
EDIT
Any non-printing characters can be converted to a dot or deleted using tr
Code:
printf $(echo "obase=16;ibase=2;$bin" | bc | sed 's/../\\x&/g') | tr -c '[:print:]' '.'

Last edited by Kenhelm; 03-17-2011 at 12:05 AM.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to convert binary file to ascii file? idaham Linux - Newbie 9 09-18-2009 03:19 AM
How to convert binary text file from Windows marie@dk Linux - Software 2 10-12-2005 03:17 AM
Convert ASCII text to an audio file ed_homeLinux Linux - Software 1 07-22-2005 12:30 PM
ASCII vs Binary the_imax General 4 12-25-2004 10:35 AM
convert text file to binary excel file ust Linux - General 2 11-23-2004 02:33 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 03:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration