LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
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 04-05-2015, 07:47 PM   #1
peonuser
Member
 
Registered: Mar 2008
Location: Where ever I am.
Distribution: Various
Posts: 177
Blog Entries: 171

Rep: Reputation: 21
fg error?


This is probably an easy fix, but it escapes me.

code:

D=date %Y-%m-%d
D1=`date +%s -d "$D"`
D2=`date +%s -d "2017-01-20"`
((diff_sec=D2-D1))
echo - | awk -v SECS=$diff_sec '{printf "Number of days : %d",SECS/(60*60*24)}'0
echo ""

runtime:

$ ./datediff.sh
./datediff.sh: line 1: fg: no job control
Number of days : 656
$

eek.. ./datediff.sh: line 1: fg: no job control
 
Old 04-05-2015, 08:41 PM   #2
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos
Posts: 269

Rep: Reputation: 54
I Think you forgot the '' around the first "D="
 
Old 04-05-2015, 11:31 PM   #3
peonuser
Member
 
Registered: Mar 2008
Location: Where ever I am.
Distribution: Various
Posts: 177
Blog Entries: 171

Original Poster
Rep: Reputation: 21
Thanx:

new code:

#!/bin/bash
D=`date +Y-%m-%d`
D1=`date +%s -d "$D"`
D2=`date +%s -d "2017-01-20"`
((diff_sec=D2-D1))
echo - | awk -v SECS=$diff_sec '{printf "Number of days : %d",SECS/(60*60*24)}'
echo " days till Obama leaves office."

runtime:

$ ./datediff.sh
Number of days : 656 days till Obama leaves office.
$

Last edited by peonuser; 04-05-2015 at 11:32 PM.
 
  


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] Fatal error in MPI_Init: Other MPI error, error stack:gethostbyname failed(errno 1) turbo67 Linux - Networking 1 08-08-2014 04:41 AM
Fatal error in MPI_Init: Other MPI error, error stack:gethostbyname failed(errno 1) turbo67 Red Hat 1 06-15-2014 06:53 AM
Fatal error in MPI_Init: Other MPI error, error stack:gethostbyname failed(errno 1) shilpiiitr Linux - Software 0 01-13-2014 03:44 PM
Error 502 : Display Fatal Error Message, Error pushing image, dbpaCT failed! HaloCheng Linux - Newbie 1 09-12-2012 01:02 PM
Sendmail: eocket wedge , 504 error , dsn error, mail relay connection error djcs Debian 0 03-03-2009 01:41 AM

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

All times are GMT -5. The time now is 12:22 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