Programming :: Converting YYYYMMDD To Date In Bash Script?

Aug 2, 2010

I need to convert strings in the format YYYYMMDD to dates so I can perform date arithmetic.

View 4 Replies


ADVERTISEMENT

Programming :: Converting Date Format In A Comma Separated Field?

Apr 9, 2010

I am in the process of learning some scripting, however I am running into a roadblock in specifying a certain time format in the array. Ideally I would like to use Here are the lines of text that I am interrogating:

1123,3/25/2010,00:14 Thu,33229
1124,3/26/2010,13:30 Fri,33230
1125,3/27/2010,04:49 Sat,33231

[code]...

View 2 Replies View Related

Programming :: Converting Epoch In A File Name To Human Readable Date/time?

May 5, 2011

I have log files that everyday are downloaded from my webserver in the format: Code: samplesite.com.xxxxxxxxxxx.gz xxxxxxxxxx is a 10 digit epoch time. I am trying to figure out a way in batch to:

1. find all of exisiting files containing the pattern (after the first run it will only be one a day)
2. Isolate the epoch string
3. convert the epoch string to human readable date/time
4. rename the original file as samplesite.com.mmddYYYY.gz

View 2 Replies View Related

Programming :: Converting Bash Script Into PHP?

Jul 5, 2011

I wrote the following as our developers won't do it for us! The rest of my programming is in PHP, any ideas on how I can get this into php?I'm in the middle of writing a reminder system which involves importing the customer data and sending out reminder emails.All the script below does is download the current report $FILEIN, compare field number 6 ($DATA) with the date($DATE), if there is a match, it checks each line in the prescription_skus.csv to see if there is a match with field number 1 in the current report. It then outputs the entire line to $FILEOUT

Code:
TODAY=`date +"%Y-%m-%d"`
FILEIN="export-"$TODAY".csv"

[code]...

View 7 Replies View Related

Programming :: Convert From DD/MM/YYYY To YYYYMMDD?

Jun 6, 2011

How does one convert from DD/MM/YYYY to YYYYMMDD?

Code:
06/06/2011
06/06/2011

to

Code:
20110606
20110606

View 6 Replies View Related

Debian Programming :: Yesterday Date In Bash Script

Jun 22, 2011

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 Related

Programming :: Bash Scripting With File Date Comparison?

Mar 23, 2011

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.

View 3 Replies View Related

Programming :: Manipulating A Date In A Perl Bash Script?

Mar 11, 2010

I'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.

View 10 Replies View Related

Programming :: Writing A Renaming Script (DDMMYYYY To YYYYMMDD Format)?

Jan 15, 2010

I have a load of photos from my old Nokia phone that I need to rename. A few examples of the current format is "ddmmyyyy.jpg", "ddmmyyyy(001).jpg", "ddmmyyyy(002).jpg" etc, where ddmmyyyy is the date.I need to rename hundreds of files in a single directory so that the first 8 digits are rearranged into "yyyymmdd.jpg", "yyyymmdd(001).jpg" format etc.Even better if the output format could be "yyyy-mm-dd_(001).jpg"

View 5 Replies View Related

Programming :: Bash Script To Copy Modification Date From A File To His Folder?

Jul 29, 2011

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 Related

Ubuntu :: Bash Command For Counting Down To A Certain Date

Jan 6, 2010

I 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 Replies View Related

Programming :: Keep Original Mod Date Of A File And 'date' It Back To Same File?

Jul 12, 2010

I would really like to preserve a file's original modified date and pass it back to the file as the same attribute after a script has worked on it. I get a lot of JPEG files from different places on the Net which I either turn around and upload or burn to disk, and having the "original" date of either download or last mod in a graphics app would be for me, in the long run, a lot more helpful when deciding, for instance, which files to "recycle" or pass on backing up more than once.I've tried doing this on my own every now and then. Where I run into problems is that it appears "stat" and "date" use different formats for date information, and I can't seem to puzzle out how to "translate" one to the other satisfactorily for the latter command.

Just to give an example:
stat foo.jpg |grep Modify gives me
Modify: 2010-07-12 06:28:56.890625000 -0400

Passing that string as-is to date foo.jpg, I get the errordate: unknown option -- 0 and the usual semi-courteous suggestion to Try 'date --help' for more information.Somehow my TexInfo database got screwed up somewhere along the line and info dategives me the short article on date input formats, not the full documentation for the command

View 4 Replies View Related

General :: Bash - Create Folders According To Date In System?

May 26, 2011

Is 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?

View 2 Replies View Related

Ubuntu :: Use The Date Command In A Simple Bash Script?

Oct 26, 2010

I 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?

View 5 Replies View Related

Ubuntu :: $(date +%k) Acts Weirdly In A Bash Script?

Jul 14, 2011

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]...

View 4 Replies View Related

General :: BASH To Find Pics And Videos With No Date Taken Exit

Aug 7, 2011

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 Related

Ubuntu :: Shell Script Using Bash / Get The Date Of The Process Takes Longer Running?

Mar 29, 2010

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.

View 9 Replies View Related

Programming :: Converting MB/TB To GB In Perl?

Jan 30, 2010

I am taking an input from the user for free and Used capacity in a disk. I wish to convert Input entered in MBTB to GB and this is how i am doing it.

Code:

<some code>
print "Enter Total disk space";
$tot = <STDIN>;
convert($tot);

[code]...

how do i pass the value of conv[0] after conversion back to $tot or $use such that they contain only value which is in GB?

View 3 Replies View Related

Programming :: Error When Converting C To C++?

Jan 22, 2011

I'm working on a project where I am converting a C file to C++. I have worked out 99% of the errors but there is still one lingering one that I cant seem to figure out. I get the following error when compiling with g++

Code:
mscp.cpp:749: error: invalid conversion from const void* to move
mscp.cpp:750: error: invalid conversion from const void* to move

[code]...

View 5 Replies View Related

Programming :: Converting ODT File To PDF Using PHP

Apr 3, 2011

My problem is to convert an odt file to pdf using php. I wrote an article in odt and I'd want to download it in pdf from my site. I know "fpdf", but it doesn't convert from odt. Someone says to convert from odt to html then to pdf... but some others says NO! Well, do you know a way? (may be also different from odt to pdf, e.g. from latex to pdf).

View 12 Replies View Related

Programming :: Converting C Code To Assembly

May 17, 2011

I've been converting some C code to assembly for my homework; it was going well but I'm having trouble with a for loop for hours. I could not understand where is the problem and decided to ask. I'm posting the part where I'm having trouble of my C-code and assembly-code; every other part of codes act same and the variable values are same. I'm waiting this two codes to act same, but they don't.

Code:
mov ebx, [result]
mov eax, [i]
mov ecx, [ebx+eax]
mov [j], ecx
mov [ebx+eax], byte '.'

_loop:
mov ebx, [result]
mov eax, [i]
inc eax
mov cl, [ebx+eax]
cmp cl, 'Z'
je _continue

mov ebx,[result]
mov eax,[i]
inc eax
mov ecx, [ebx+eax]
mov [k], ecx
mov ebx, [result]
mov eax, [i]
inc eax
mov ecx, [j]
mov [ebx+eax], ecx
mov ecx, [k]
mov [j], ecx
inc dword [i]
jmp _loop

_continue:
Code:
j=result[i];
result[i]='.';
for(;result[i+1]!='Z';i++){
k=result[i+1];
result[i+1]=j;
j=k;
}

View 10 Replies View Related

Programming :: GMP And Converting Mpz_t To Char?

Jul 16, 2011

I'm writing the Diffie-Hellman key exchange system using GMP to handle big integers. For the most part, everything works. I can convert the string to mpz_t, set up the keys and everything, and encrypt it fine. Its the decrypting I'm having issues with. What I'm using is mpz_xor() for both. To encrypt I'm doing mpz_xor(buffer, mpz_of_text, secret_key), and to decrypt I'm doing mpz_xor(buffer, mpz_of_cipher, secret_key).

For one character, it semi-works...it'll decrypt it fine, but it'll return it as it's ASCII value (i.e.: if I encrypt "A", it'll decrypt it as 65). Which, I can easily just do sprintf(decrypted_buffer, "%c", 65) for example and be fine. But, when I'm sending text bigger than one character, the encryption for AB gives me something like 1061043 after running the decrypting xor on it.

Has anyone ever done this before or can point me in some directions? Perhaps other algorithms to try? I know XOR isn't the most secure encryption method to use, but at the time I wasn't sure what else to use. I'm really just having a hard time trying to convert a mpz_t to a character string. I've looked at mpz_get_str() and it works before running encryption (i.e.: using mpz_set_str() to create a mpz of a string, then calling mpz_get_str() to change it back). Maybe my XOR method is wrong? Here's the code I'm using:

Code:

/**
* str2mpz()
* b The current buffer of text to convert [in]
* m The mpz_t variable to store converted text [out]

[code]....

View 9 Replies View Related

Programming :: Converting C Code To C++ Causes An Type Error?

Mar 25, 2010

I'm a C / assembler programmer so am not use to C++, which I need to use. Basically I'm using my own versions of memcpy, but for long and int rather than char. It's for fast graphics. So I have a char array which I copy to another array. But I copy as either longs or ints, much faster. for example

Code:
void * fastmemcpysprite (void *destaddr, void const *srcaddr, size_t len)
{

[code]...

View 3 Replies View Related

Programming :: Converting Perl Script To Python?

Jul 21, 2011

#!/usr/bin/perl
print "Input File Name: ";
$filename = <>;
$filename =~ s/s+$//;mkdir "$filename";

[code]....

View 3 Replies View Related

Programming :: Converting Vector Of Bytes To String C++

Mar 4, 2011

I have a vector of octets that needs to be converted to a std string. I'm currently doing it this way:

Code:
stringstream ss;
for (unsigned int i=0; i < data.size(); i++
{
ss << data[i];
}
string s_data = ss.str();

This works, but is there any better way to do it?

View 2 Replies View Related

Programming :: Bash: Printing The Line Number In Bash Script?

Feb 4, 2011

I would like to know how do I print the line # in a script. My requirement is, I have a script which is about ~5000 lines long. If there are any errors happen I just exit. And I would like to add the line # of the script where the error happened.

View 3 Replies View Related

Programming :: Bash Ctrl+c Tarp And Bash Read With Timeout?

Jan 24, 2010

simple bash code:

Code:
#!/bin/bash
trap "echo 'you got me'" SIGINT SIGTERM # to trap ctrl+c
echo "Press ctrl+c during 5 sec loop"
for ((i=0;i<5;i++)); do

[Code]...

How come code behaves normally and stops when ctrl+c signal is caught and resumes, but after I use at least one timeout read in the code it looks like, if signal is caught again it doesn't pause the execution but skips the loop. If you remove -t (timeout) option from the read, both loops look the same!

View 10 Replies View Related

Programming :: Converting String Sequence Of 1's And 0's Into Their Hexa Sequences

Apr 27, 2011

I have to write a code that converts a sequence of 1's and 0's(block) into their equivalent hexa number and copying to another array(byte). but this sequence is not always of length 8 and you are required to send strlen(sequence)%8 bits back into the string. So i've written down this code and it works well with the sample input but fails in the real program.

Code:
int Convert_encode( char * block,unsigned char * byte)
{
int len,iter,i,j,k,sum;
char * temp=(char *)malloc(4*sizeof(char));
len=strlen(block)/8;

[code]....

View 7 Replies View Related

Programming :: Reading A Bash Variable In Bash Scripting ?

Nov 26, 2008

I have a config file that contains:

my.config:

Code:

Now in my bash script, I want to get the output /home/user instead of $HOME once read. So far, I have managed to get the $HOME variable but I can't get it to echo the variable. All I get is the output $HOME.

Here is my parse_cmd script:

Code:

View 3 Replies View Related

Programming :: Run Multiple Bash And Php Scripts From A Bash Script?

Jul 25, 2011

I have written quite a few separate bash & scripts and php scripts that up to now I have run from cron jobs. However I have to estimate how long each takes to run, before running the next and so it probably takes much longer than necessary to run them all. They have to run in order.

Now there are so many I am thinking it would be better to have a master bash script that would run one after the other, but I am not sure how to get the master script to wait before starting to run the next script. Is this possible and is there a command that will make the script wait between bash and php scripts , for them to finish, before running the next?

View 5 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved