LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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, 06:47 PM   #1
peonuser
Member
 
Registered: Mar 2008
Location: Where ever I am.
Distribution: Various
Posts: 177
Blog Entries: 172

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, 07:41 PM   #2
ArfaSmif
Member
 
Registered: Oct 2008
Location: Brisbane Australia
Distribution: Fedora, Centos, Manjaro
Posts: 317

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

Original Poster
Blog Entries: 172

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

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

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