Ubuntu :: Bash Command For Counting Down To A Certain Date
Jan 6, 2010I would like to write a shell script that displays the number of days, hours and seconds left until a certain date and time. What commands would I use?
View 6 RepliesI would like to write a shell script that displays the number of days, hours and seconds left until a certain date and time. What commands would I use?
View 6 RepliesI am trying to use the date command in a simple bash script as below:
#!/bin/sh
this_date=`date`
echo "The date is $this_date"
This script seems to work only if a surround the command with the `` characters, which I copied from another script. Can anyone tell me why this is, and how I can insert these characters from my keyboard,which only has normal quote and double-quote characters?
If I read in variables entered by the user, how can I check to make sure the correct number of variables were entered? For example, after reading in a data file and making it into an array, I have:echo "To check the data, enter the first element number, last element number and step size as x y z:"read x y z.It then goes on to start a loop, but what I would like now (before the loop) is a check to see if three variables have been entered, before the rest of the script continues.
I've tried specifying the variables as $1, $2 and $3, but if I echo $#, the value comes out as zero, so it's obviously not working.
Is there a way to count the number of errors- an exit variable $? from one function?
The output from the exit variable (either erroneous or correct (1) or (0)) is it possible to add the erroneous one ups?
This might well be a case of "I've been looking at terminals for far too long", but here goes. In a bash script I'm writing I'd like to get the current minute of the day. Since date doesn't have an in-built format string for that, I thought I would do:minute of day = 60 * hour of day + minute of hourHowever, when the clock rolled around to 12 / 0 the value disappears from the variable. Viz:
Code:
hour=$(date +%k)
echo "hour: $hour"
[code]...
I have used "FILENAME="`TZ=$TZ+24 date +%y%m%d`" in a bash script that run in openbsd. What my script does is to changes a file name to "yesterdays date". I tried to use it in a script that runs in debian but it doesnt work. Is there any other command that i can use in debian?
View 3 Replies View RelatedIs there any other short/easier and smarter way to do the following in Linux? code...
I need to use crontab to create folders every day and every month inside /home/abcd/dammi, /home/abcd/harrami, /home/wxyz/dammi and /home/wxyz/harrami. Can anyone help me with this?
I need to be able to compare a file date with system date and delete files older than 30 days.
the file name is basically
error_log.03222011
of course the extension is the date the file was created.
Oh and before i get hammered I looked everywhere but am unable to make sense of what I found.
I need to convert strings in the format YYYYMMDD to dates so I can perform date arithmetic.
View 4 Replies View RelatedI've recently inherited a bunch of files at a new job and am trying to figure out some of the problems that have constantly popped up. The one i'm getting a huge headache with results from a bash script that is supposed to change a date format from a client populated txt field to one we want defined a certain way. Everything in the script works fine, except that one function. Below is the line i'm trying to manipulate, with date examples.
sed -e 's/.0000 EA/ EA/' -e 's/ 01012010 / 01-JAN-2010 /' -e 's/ 12312011 / 31-DEC-2011 /'
The one caveat is that the first date is non-static and changes daily. It is, however, always the current date. If it helps, the second date will always be a year away from the first date.My idea was to pull the current date via perl's DATE function, but...how to do it, and calculate a year away without throwing the rest of the bash script off? Any help would be appreciated. I'm sure it's a simple solution but i know absolutely nothing about these scripts and how they were written.
I need show the number of process per user, and after the date of the oldest process per user also.
With "ps -eo user | sort -u" i get all users that are running any process. And with "ps U username | wc -l" i get the number of process that the user "username" is running.
But how can i merge both commands for do what i need? Like a FOR or something like that. There is any method of make a FOR using the list that i get with the first command?
And then for show the date of the oldest process.. with "ps U username | sort -k 4" (4 is TIME field) i can show the process of the user "username" sorting they by time. But how can i get the date of the process takes longer running?? I can get only the time, but no the date.
Is there a script to do this? I have shotwell and want to find files that are going to cause problems with automatic sorting.
View 3 Replies View RelatedI got a problem with terminal, since i'm really a noob with terminal i don't know how to fix it.Everytime i type in a command it shows for example:
-bash: ls: command not found
Even the basic commands don't work... just cd <directory> and those things works
I need this script but I don't know how to do it I have one folder with several folders inside.On each folder a have one MKV or AVI file inside...What I need is a script to change the "modification date" of each folder to the "modification date" of each MKV or AVI that the folder has inside.
View 16 Replies View RelatedI create a bash script that writes another bash file. But in the generated bash file I want to write a bash command in the file and not executing it.Here's my bash file:
Code:
#!/bin/bash
cat > ~/generateGridmix2data.sh << END
[code]...
What is the name of the package for "/bin/date" command. need to re-install
how can I determine that a spesific file belongs to which package?
using ubuntu 10.04 64bit
How to use the date command to display, for example, 10-Mar-2010 01:01:53? What's the format string?
View 2 Replies View RelatedI just recently learned about the wonderful little lpr command- and using man -t (bash command) to beautifully print man pages for reference- but is there a way to print both sides of the paper using a printer so equipped?
View 2 Replies View RelatedI have a big bash script ,its goal is to download movie one by one . But I often get into a problem: if this script is executed in cron,it often does not completely download the movie.I often find the movies it downloaded are several KB while the movie is actually 20MB.So I think it is because it did not wait for finishing one task ,and jump to download another.So I want to know ,is there a way to force the bash script to wait until one movie downloaded completely and then start to download another movie ?
View 8 Replies View RelatedI would appreciate help with how to extract the date and time from at command jobs. From what I can tell, the date and time is embedded in the file name (/var/spool/atjobs).I'd be using this information in a (bash) shell script.
View 14 Replies View RelatedI need to pipe the output of date command, to form a command like this:
mycommand -f 20110721
where 20110721 is current YearMonthDay.
I'm writing a script that takes the date attribute of a file when it was created and appending it to the name. I'm pretty close to what I need, but the date appears in yyyy-mm-dd format and I want it to read mm-dd-yyyy. What I have done so far is something like
for ((i=1;i<=50;i++));
do fdate=`stat -c %y Video Snapshot $i.png|awk {'print$1'}`;
newname=Personname-$fdate-$i.png;
mv Video Snapshot $i.png $newname;
done
This works decently but the date comes out in the yyyy-mm-dd format. How do I change it?
Bash's command history is great, especially it is useful when adding the history -a command to the COMMAND_PROMPT.However, I'm wondering if there is a way to log the commands to a file as soon as the Return key is pressed, e.g. before starting the command and not on completion of the command (using the COMMAND_PROMPT option would save the command once the prompt is there again).
I read about auditing programs like snoopy and session recorder like script but I thought they're already too complex for the simple question I have. I guess that deactivating that script logs all the output of the command would lead already in the right direction but isn't there a quicker way to solve that probelm?
I am doing some NSCA log parsing and I want to get an output like this:
2011-Feb-18:11:00:07
2011-Feb-18:11:00:07
2011-Feb-18:11:00:07
2011-Feb-18:11:00:08
2011-Feb-18:11:00:08
[Code]....
I have tried this, but it treats the entire output as a single line, then plops a timestamp on the end (I think):
Code:
sort -b -k4.9,4.12 -k4.5b,4.7Mb -k4.2,4.3 -k4.14,4 foo.log| date -j -f "%Y-%b-%d:%T" "+%s" "`awk -F '[ [/:]' '{print $7"-"$6"-"$5":"$8":"$9":"$10}'`"
I am doing some NSCA log parsing and I want to get an output like this:
2011-Feb-18:11:00:07
2011-Feb-18:11:00:07
2011-Feb-18:11:00:07
[code]...
i need to add the date of the root of the command prompt line, i can get it show to the date for any user how do i just do it for root? and i added it to the .bash_profile file
export PS1='[`date +%D` u@h W]$ '
what is the tool to get the history inclduing the user name,command time and from which file/folder the command is executed.
View 1 Replies View RelatedHow can format the date command to output the following format 08-Dec-2010.
View 3 Replies View RelatedPossible Duplicate: What does this cryptic bash command mean? Why this command crashes Linux? :(){ :|:& };:
View 4 Replies View RelatedWhat's the command to delete bash command history?
View 4 Replies View Related