Register
It is currently Wed Jul 23, 2014 8:19 pm

Let Commands?


All times are UTC - 6 hours


Post new topic Reply to topic  [ 4 posts ] 
Author Message
 PostPosted: Mon May 16, 2011 3:46 pm   

Joined: Mon May 16, 2011 3:35 pm
Posts: 2
Hi,

I've been searching online to try to find all the actual let commands. I was hoping someone on here could help me out. Basically, I am trying to do two things, one of which I have figured out.

First thing was to removing a 0 from a three digit number.
I set my variable
a=023
I than run my let command
let a2="10#$a"
echo $a2
23

in the end, the script outputs - 023.23

Now, can anyone let me know how to add a 0? IE - if a user, if the user just types 23 my output becomes 23.23 instead of 023.23 like I want.

Thanks in advance!


Top
 Profile  
 PostPosted: Mon May 16, 2011 4:28 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 532
Hi,

should 'a' always be three digits?


Top
 Profile  
 PostPosted: Mon May 16, 2011 4:31 pm   

Joined: Mon May 16, 2011 3:35 pm
Posts: 2
Yes it should. And I think I found the solution, correct me if I'm wrong.

if [ $INTERACTIVE -eq 1 ]; then
# Prompt for input and validate:
read -p "Enter number (q=quit): " A ; A=$(printf "%03d" $A)
[ "X${SITENUM}" = "Xq" ] && warn_exit


Top
 Profile  
 PostPosted: Mon May 16, 2011 5:04 pm   

Joined: Mon Mar 02, 2009 3:03 am
Posts: 532
yes, more or less
Code:
if (( interactive == 1 ))
then
   # Prompt for input and validate:
   read -p "Enter number (q=quit): " A
   [ "$site_num" = "q" ] && warn_exit || printf -vA '%03d' $A
etc
fi


Top
 Profile  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 12 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron


BashScripts | Promote Your Page Too
Powered by phpBB © 2011 phpBB Group
© 2003 - 2011 USA LINUX USERS GROUP