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-2012, 02:09 AM   #1
chumpp
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Rep: Reputation: Disabled
Bash shell script problems need help ASAP!


Thanks for the help!!

Last edited by chumpp; 03-16-2012 at 06:32 PM.
 
Old 03-16-2012, 03:16 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Hi,

The date command can do what you want/need:
Code:
date '+%l' -d 23
11
If you also need the am/pm string:
Code:
date '+%l %p' -d 23
11 PM
See man date for details.

BTW:
- please use [code]...[/code] around your code.
- Do not use ASAP. It might be urgent for you, but it sure isn't for us. We are volunteers.

Hope this helps.
 
Old 03-16-2012, 09:57 AM   #3
chumpp
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Thanks so much Druuna

Last edited by chumpp; 03-16-2012 at 06:32 PM.
 
Old 03-16-2012, 12:24 PM   #4
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390Reputation: 2390
Hi,
Quote:
Originally Posted by chumpp View Post
I'm still kinda lost so should i do
Code:
date '+%l' -d 23
when i put the code in it just turned all the time to 11.
Yes, it is an example with a fixed time (23). Substitute 23 with the actual time you want to use.

It seems that this line stores your time value:
Code:
time=`grep $day p2.input2|cut -d " " -f 2`
You could do something like this:
Code:
fulltime=`grep $day p2.input2|cut -d " " -f 2`
time=$(date '+%l' -d ${fulltime})
All this can probably done more elegant and resource friendly, but with the info given I cannot help in that respect.

Hope this helps.
 
Old 03-16-2012, 05:04 PM   #5
chumpp
LQ Newbie
 
Registered: Mar 2012
Posts: 12

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by druuna View Post
Hi,
Yes, it is an example with a fixed time (23). Substitute 23 with the actual time you want to use.

It seems that this line stores your time value:
Code:
time=`grep $day p2.input2|cut -d " " -f 2`
You could do something like this:
Code:
fulltime=`grep $day p2.input2|cut -d " " -f 2`
time=$(date '+%l' -d ${fulltime})
All this can probably done more elegant and resource friendly, but with the info given I cannot help in that respect.

Hope this helps.
ah ok see i tried that but i did it like this time=$(date '+%l' -d {$fulltime}) and it wouldn't work i see how i did not need the $. Thanks so much for your help!
 
  


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
Calling a bash shell script from within another script dedman Linux - Software 7 04-24-2010 09:53 PM
in bash shell how to run shell script during startup rammohan04 Red Hat 2 07-31-2009 03:07 AM
help with bash shell script !! taiwf Linux - Newbie 5 06-11-2006 07:07 PM
Problems with a script (bash shell, Red Hat 7.2) illiniguy3043 Linux - Newbie 7 06-01-2004 02:49 AM
bash/shell script mikis Programming 2 10-14-2003 12:39 PM

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

All times are GMT -5. The time now is 02:38 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration