Sponsored Content
Special Forums Windows & DOS: Issues & Discussions Simple 'date' to 001 scheme script Post 302958107 by rbatte1 on Monday 19th of October 2015 11:37:01 AM
Old 10-19-2015
Dear pasc,

I have a few to questions pose in response first:-
  • Is this homework/assignment? There are specific forums for these.
  • What have you tried so far?
  • What output/errors do you get?
  • What OS and version are you using?
  • What are your preferred tools? (C, shell, perl, awk, etc.)
  • What logical process have you considered? (to help steer us to follow what you are trying to achieve)
Most importantly, What have you tried so far?

Assuming that you have less than 1000 files, you could:-
  • Set up a three digit counter padded with leading zeros
  • List the files sort in date order, oldest first (reversed to normal date order) using ls -1rt
  • Use this list as input to a loop to rename each source file in turn to the appropriate numbered file
  • Increment the counter and go round the loop to the end of the list.

There are probably many ways to achieve most tasks, so giving us an idea of your style and thoughts will help us guide you to an answer most suitable to you so you can adjust it to suit your needs in future.


We're all here to learn and getting the relevant information will help us all.


Kind regards,
Robin

Last edited by rbatte1; 10-19-2015 at 12:38 PM.. Reason: Polite closing and clarity
 

10 More Discussions You Might Find Interesting

1. Tips and Tutorials

Simple date and time calulation in BASH

The GNU date command in full of goodies but not when it comes to calculate a date or time difference. Here is what I came up with after looking to more than one solution. Code should be self explaining. #!/bin/bash date2stamp () { date --utc --date "$1" +%s } stamp2date (){ ... (0 Replies)
Discussion started by: ripat
0 Replies

2. HP-UX

a simple way of converting a date in seconds to normal date

Hi all! I'm working on a HPUX system, and I was wondering if there is a simple way to convert a date from seconds (since 1970) to a normal date. Thanks (2 Replies)
Discussion started by: travian
2 Replies

3. Shell Programming and Scripting

simple date problem

i have a script that grep for today date a=`date +"%F"`--------greps current/today date wat if suppose i want to grep a date for yesterday... how to do that using the above format: i,e 2008-01-20 (4 Replies)
Discussion started by: ali560045
4 Replies

4. Shell Programming and Scripting

Simple date formatting?

Hi guys, I have some embedded perl within my shell script to get me the modification time/date of a file which returns me the following string: Fri May 1 09:52:58 2009 I have managed to get the bits i need such as 1-May-2009, but what i would prefer is 010509 instead... Here is my... (4 Replies)
Discussion started by: muay_tb
4 Replies

5. Shell Programming and Scripting

Simple date issue

Hi all, i have used the search already before someone shouts at me and i have seen the 'datecalc' program but this is not working correctly for me in the shell and environment i am using. I am using solaris 10 and bourne shell. I have two dates '07-04-2009' and '05-05-2009'. I just need to... (2 Replies)
Discussion started by: muay_tb
2 Replies

6. Shell Programming and Scripting

How can get the value 001 using shell script

Hi Gurus, Please help in this shell script. x=000 y=`expr $x + 1` echo $y which gives me the value as 1 How can i get the value as 001 in this shell script. As i am new to scripting stuck up here. Requesting here help here (2 Replies)
Discussion started by: nmadhuhb
2 Replies

7. Shell Programming and Scripting

Help making simple perl or bash script to create a simple matrix

Hello all! This is my first post and I'm very new to programming. I would like help creating a simple perl or bash script that I will be using in my work as a junior bioinformatician. Essentially, I would like to take a tab-delimted or .csv text with 3 columns and write them to a "3D" matrix: ... (16 Replies)
Discussion started by: torchij
16 Replies

8. Shell Programming and Scripting

Simple date and time calulation in BASH

There is a closed Thread: <url>Here will be the url to the original post once I have 5 posts in this forum...</url> But a small bug had found his way into this very cool and simple code. #!/bin/bash date2stamp () { date --utc --date "$1" +%s } stamp2date (){ date --utc --date... (2 Replies)
Discussion started by: frood
2 Replies

9. Shell Programming and Scripting

Simple date issue

Hi , Here is the smaller version of the problem. Working individually as command ************************>echo $SHELL /bin/bash ************************>TO_DAY=`date` ************************>echo $TO_DAY Tue Jul 16 02:28:31 EDT 2013 ************************> Not working when... (5 Replies)
Discussion started by: Anupam_Halder
5 Replies

10. Shell Programming and Scripting

How to do simple date (time) calculation in shell script?

Hi, I'm looking for a way to do a simple math calc during a shell script as a means of logging how long a particular task takes. For example... STARTTIME=whenever this script starts ./path/to/command.sh >>logfile.log TOTALTIME=<time at this stage of the script after above command... (7 Replies)
Discussion started by: nbsparks
7 Replies
Round(3pm)						User Contributed Perl Documentation						Round(3pm)

NAME
Math::Round - Perl extension for rounding numbers SYNOPSIS
use Math::Round qw(...those desired... or :all); $rounded = round($scalar); @rounded = round(LIST...); $rounded = nearest($target, $scalar); @rounded = nearest($target, LIST...); # and other functions as described below DESCRIPTION
Math::Round supplies functions that will round numbers in different ways. The functions round and nearest are exported by default; others are available as described below. "use ... qw(:all)" exports all functions. FUNCTIONS
round LIST Rounds the number(s) to the nearest integer. In scalar context, returns a single value; in list context, returns a list of values. Num- bers that are halfway between two integers are rounded "to infinity"; i.e., positive values are rounded up (e.g., 2.5 becomes 3) and neg- ative values down (e.g., -2.5 becomes -3). round_even LIST Rounds the number(s) to the nearest integer. In scalar context, returns a single value; in list context, returns a list of values. Num- bers that are halfway between two integers are rounded to the nearest even number; e.g., 2.5 becomes 2, 3.5 becomes 4, and -2.5 becomes -2. round_odd LIST Rounds the number(s) to the nearest integer. In scalar context, returns a single value; in list context, returns a list of values. Num- bers that are halfway between two integers are rounded to the nearest odd number; e.g., 3.5 becomes 3, 4.5 becomes 5, and -3.5 becomes -3. round_rand LIST Rounds the number(s) to the nearest integer. In scalar context, returns a single value; in list context, returns a list of values. Num- bers that are halfway between two integers are rounded up or down in a random fashion. For example, in a large number of trials, 2.5 will become 2 half the time and 3 half the time. nearest TARGET, LIST Rounds the number(s) to the nearest multiple of the target value. TARGET must be positive. In scalar context, returns a single value; in list context, returns a list of values. Numbers that are halfway between two multiples of the target will be rounded to infinity. For example: nearest(10, 44) yields 40 nearest(10, 46) 50 nearest(10, 45) 50 nearest(25, 328) 325 nearest(.1, 4.567) 4.6 nearest(10, -45) -50 nearest_ceil TARGET, LIST Rounds the number(s) to the nearest multiple of the target value. TARGET must be positive. In scalar context, returns a single value; in list context, returns a list of values. Numbers that are halfway between two multiples of the target will be rounded to the ceiling, i.e. the next algebraically higher multiple. For example: nearest_ceil(10, 44) yields 40 nearest_ceil(10, 45) 50 nearest_ceil(10, -45) -40 nearest_floor TARGET, LIST Rounds the number(s) to the nearest multiple of the target value. TARGET must be positive. In scalar context, returns a single value; in list context, returns a list of values. Numbers that are halfway between two multiples of the target will be rounded to the floor, i.e. the next algebraically lower multiple. For example: nearest_floor(10, 44) yields 40 nearest_floor(10, 45) 40 nearest_floor(10, -45) -50 nearest_rand TARGET, LIST Rounds the number(s) to the nearest multiple of the target value. TARGET must be positive. In scalar context, returns a single value; in list context, returns a list of values. Numbers that are halfway between two multiples of the target will be rounded up or down in a random fashion. For example, in a large number of trials, "nearest(10, 45)" will yield 40 half the time and 50 half the time. nlowmult TARGET, LIST Returns the next lower multiple of the number(s) in LIST. TARGET must be positive. In scalar context, returns a single value; in list context, returns a list of values. Numbers that are between two multiples of the target will be adjusted to the nearest multiples of LIST that are algebraically lower. For example: nlowmult(10, 44) yields 40 nlowmult(10, 46) 40 nlowmult(25, 328) 325 nlowmult(.1, 4.567) 4.5 nlowmult(10, -41) -50 nhimult TARGET, LIST Returns the next higher multiple of the number(s) in LIST. TARGET must be positive. In scalar context, returns a single value; in list context, returns a list of values. Numbers that are between two multiples of the target will be adjusted to the nearest multiples of LIST that are algebraically higher. For example: nhimult(10, 44) yields 50 nhimult(10, 46) 50 nhimult(25, 328) 350 nhimult(.1, 4.512) 4.6 nhimult(10, -49) -40 STANDARD FLOATING-POINT DISCLAIMER Floating-point numbers are, of course, a rational subset of the real numbers, so calculations with them are not always exact. In order to avoid surprises because of this, these routines use a value for one-half that is very slightly larger than 0.5. Nevertheless, if the num- bers to be rounded are stored as floating-point, they will be subject, as usual, to the mercies of your hardware, your C compiler, etc. Thus, numbers that are supposed to be halfway between two others may be stored in a slightly different way and thus behave surprisingly. AUTHOR
Math::Round was written by Geoffrey Rommel <GROMMEL@cpan.org> in October 2000. perl v5.8.8 2006-12-02 Round(3pm)
All times are GMT -4. The time now is 08:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy