LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-24-2006, 05:42 AM   #1
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Rep: Reputation: 15
convert decimal to octal using the let command


Hey guys,

I am trying to convert decimal to octal numbers in the shell on my linux box.
I do not want to go the hard way and write my own converter so I googeled and found the command let which lets you convert numbers from octal and hexadecimal to decimal.

Is there a way to do it the other way around like I need? Maybe with the let command?

THX

Suinatsa
 
Old 10-24-2006, 08:37 AM   #2
jim mcnamara
Member
 
Registered: May 2002
Posts: 964

Rep: Reputation: 36
Code:
let i=10
printf "%o\n" $i
Converts 10 in decimal to 12 in octal

edit - typo...

Last edited by jim mcnamara; 10-24-2006 at 04:22 PM.
 
Old 10-24-2006, 08:42 AM   #3
Suinatsa
Member
 
Registered: Jul 2004
Distribution: Slackware, Suse
Posts: 46

Original Poster
Rep: Reputation: 15
Hey,

thanks that is exactly what I needed!
For all the noobs who may find this answer. Its

printf "%o\n" $i

Suinatsa
 
  


Reply



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
is there a command to convert text to speech? syssyphus Linux - General 3 05-02-2006 02:35 PM
error when using a system command to invoke convert nodyl Programming 4 08-25-2004 10:00 PM
Have problem converting a decimal number to octal Linh Programming 4 05-20-2004 03:21 PM
C, read 8 bit octal numbers, convert to 24 bit binary bamalabs Programming 3 01-20-2004 09:59 AM
Can 't convert from a character to octal value in memory Linh Programming 2 07-21-2003 03:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:52 PM.

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
Open Source Consulting | Domain Registration