Sponsored Content
Top Forums Shell Programming and Scripting Renaming mutiple files with hyphens in name Post 302502343 by mvijayv on Monday 7th of March 2011 05:20:42 PM
Old 03-07-2011
Thanks Alister .. dont know what started me off with that approach a long time ago .. but never too late to get over a bad habit ... Good info, Thanks!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Report with mutiple files.

Hi all, In the process of creating CPU reports. I've already used `sar` to create a daily file, then monthly reports for CPU usage (which is averaged across all 4 CPU's). I've now used `cpusar -P ?`(?=CPU#) to collect individual CPU data and have four files for each day which is great. The... (4 Replies)
Discussion started by: Cameron
4 Replies

2. Shell Programming and Scripting

removing mutiple files

I have a script which removes files (if they exist) Here is a cut down example of the script. Variables file1,file2 etc have already been initialized #!/bin/bash if then \rm file1 fi if then \rm file2 fi if then \rm file3 fi if then \rm file4 (9 Replies)
Discussion started by: run_time_error
9 Replies

3. Shell Programming and Scripting

Sending mutiple files thru email to lotus notes

Hi All, I am currently using the following script to send the single file to one/more email addresses. I need to send mutilple files at same time, are there anyway I could modify the script or write new one to accomplish the same. Script *************** #!/bin/ksh # Author: Manish... (4 Replies)
Discussion started by: lapisguy
4 Replies

4. Shell Programming and Scripting

Mutiple For loops - moving files to another directory

I need to clean out some application subdirectories from backup scripts we used to rename to various backup extensions just in case the script failed in production and we need to rollback. I will be moving these old scripts to a staging directory and then removing them after 30 days (I have the... (9 Replies)
Discussion started by: tekster757
9 Replies

5. UNIX for Dummies Questions & Answers

copy mutilple files to mutiple folders

Hi, I just started to learn shell progamming and just can't get my head around the following problem. I need to do the following: I have a folder which contains 100+ subfolders. Inside these subfolders there is one folder named 'Morph' and several jpg's. I need to copy all the files into... (4 Replies)
Discussion started by: M474746
4 Replies

6. UNIX for Advanced & Expert Users

Remove first line from mutiple files

How to remove the first line from multiple files and use it as source to the jobs. Only at the runtime it should remove the first line not in the file . (1 Reply)
Discussion started by: etldeveloper
1 Replies

7. Shell Programming and Scripting

how to replace words in mutiple files under the same directory

I would like to get help to find how to replace word in files from command line instead of to vi to each file. This is the command i am running now. grep <old word> * vi (file with the word found in it) 1,$s/<old word>/<new word>/g It would very helpful if I can combine these in one... (2 Replies)
Discussion started by: ywu081006
2 Replies

8. Shell Programming and Scripting

paste mutiple files in a loop

file1.txt file2.txt file3.txt desired output is each file is in the same directory, hasthe same number of columns but different rows. i want to be able to paste them into one file. thanks! (5 Replies)
Discussion started by: johnkim0806
5 Replies

9. Shell Programming and Scripting

Using grep with hyphens

This is on a RHEL 6 box with bash 4.1.2 I'm trying to to use grep to only find those lines containing matches that form whole words. The -w option works fantastic unless of course that word has a hyphen. The problem is I will get a hit on "test-group" which is a good thing, but I will also... (3 Replies)
Discussion started by: woodson2
3 Replies

10. Shell Programming and Scripting

Split large xml into mutiple files and with header and footer in file

Split large xml into mutiple files and with header and footer in file tried below it splits unevenly and also i need help in adding header and footer command : csplit -s -k -f my_XML_split.xml extrfile.xml "/<Document>/" {1} sample xml <?xml version="1.0" encoding="UTF-8"?><Recipient>... (36 Replies)
Discussion started by: karthik
36 Replies
Duration(3)						User Contributed Perl Documentation					       Duration(3)

NAME
Time::Duration - rounded or exact English expression of durations SYNOPSIS
Example use in a program that ends by noting its runtime: my $start_time = time(); use Time::Duration; # then things that take all that time, and then ends: print "Runtime ", duration(time() - $start_time), ". "; Example use in a program that reports age of a file: use Time::Duration; my $file = 'that_file'; my $age = $^T - (stat($file))[9]; # 9 = modtime print "$file was modified ", ago($age); DESCRIPTION
This module provides functions for expressing durations in rounded or exact terms. In the first example in the Synopsis, using duration($interval_seconds): If the "time() - $start_time" is 3 seconds, this prints "Runtime: 3 seconds.". If it's 0 seconds, it's "Runtime: 0 seconds.". If it's 1 second, it's "Runtime: 1 second.". If it's 125 seconds, you get "Runtime: 2 minutes and 5 seconds.". If it's 3820 seconds (which is exactly 1h, 3m, 40s), you get it rounded to fit within two expressed units: "Runtime: 1 hour and 4 minutes.". Using duration_exact instead would return "Runtime: 1 hour, 3 minutes, and 40 seconds". In the second example in the Synopsis, using ago($interval_seconds): If the $age is 3 seconds, this prints "file was modified 3 seconds ago". If it's 0 seconds, it's "file was modified just now", as a special case. If it's 1 second, it's "from 1 second ago". If it's 125 seconds, you get "file was modified 2 minutes and 5 seconds ago". If it's 3820 seconds (which is exactly 1h, 3m, 40s), you get it rounded to fit within two expressed units: "file was modified 1 hour and 4 minutes ago". Using ago_exact instead would return "file was modified 1 hour, 3 minutes, and 40 seconds ago". And if the file's modtime is, surprisingly, three seconds into the future, $age is -3, and you'll get the equally and appropriately surprising "file was modified 3 seconds from now." FUNCTIONS
This module provides all the following functions, which are all exported by default when you call "use Time::Duration;". duration($seconds) duration($seconds, $precision) Returns English text expressing the approximate time duration of abs($seconds), with at most "$precision || 2" expressed units. (That is, duration($seconds) is the same as duration($seconds,2).) For example, duration(120) or duration(-120) is "2 minutes". And duration(0) is "0 seconds". The precision figure means that no more than that many units will be used in expressing the time duration. For example, 31,629,659 seconds is a duration of exactly 1 year, 1 day, 2 hours, and 59 seconds (assuming 1 year = exactly 365 days, as we do assume in this module). However, if you wanted an approximation of this to at most two expressed (i.e., nonzero) units, it would round it and truncate it to "1 year and 1 day". Max of 3 expressed units would get you "1 year, 1 day, and 2 hours". Max of 4 expressed units would get you "1 year, 1 day, 2 hours, and 59 seconds", which happens to be exactly true. Max of 5 (or more) expressed units would get you the same, since there are only four nonzero units possible in for that duration. duration_exact($seconds) Same as duration($seconds), except that the returned value is an exact (unrounded) expression of $seconds. For example, duration_exact(31629659) returns "1 year, 1 day, 2 hours, and 59 seconds later", which is exactly true. ago($seconds) ago($seconds, $precision) For a positive value of seconds, this prints the same as "duration($seconds, [$precision]) . ' ago'". For example, ago(120) is "2 minutes ago". For a negative value of seconds, this prints the same as "duration($seconds, [$precision]) . ' from now'". For example, ago(-120) is "2 minutes from now". As a special case, ago(0) returns "right now". ago_exact($seconds) Same as ago($seconds), except that the returned value is an exact (unrounded) expression of $seconds. from_now($seconds) from_now($seconds, $precision) from_now_exact($seconds) The same as ago(-$seconds), ago(-$seconds, $precision), ago_exact(-$seconds). For example, from_now(120) is "2 minutes from now". later($seconds) later($seconds, $precision) For a positive value of seconds, this prints the same as "duration($seconds, [$precision]) . ' later'". For example, ago(120) is "2 minutes later". For a negative value of seconds, this prints the same as "duration($seconds, [$precision]) . ' earlier'". For example, later(-120) is "2 minutes earlier". As a special case, later(0) returns "right then". later_exact($seconds) Same as later($seconds), except that the returned value is an exact (unrounded) expression of $seconds. earlier($seconds) earlier($seconds, $precision) earlier_exact($seconds) The same as later(-$seconds), later(-$seconds, $precision), later_exact(-$seconds). For example, earlier(120) is "2 minutes earlier". concise( function( ... ) ) Concise takes the string output of one of the above functions and makes it more concise. For example, "ago(4567)" returns "1 hour and 16 minutes ago", but "concise(ago(4567))" returns "1h16m ago". I18N/L10N NOTES Little of the internals of this module are English-specific. See source and/or contact me if you're interested in making a localized version for some other language than English. BACKSTORY
I wrote the basic "ago()" function for use in Infobot ("http://www.infobot.org"), because I was tired of this sort of response from the Purl Infobot: me> Purl, seen Woozle? <Purl> Woozle was last seen on #perl 20 days, 7 hours, 32 minutes and 40 seconds ago, saying: Wuzzle! I figured if it was 20 days ago, I don't care about the seconds. So once I had written "ago()", I abstracted the code a bit and got all the other functions. CAVEAT
This module calls a durational "year" an interval of exactly 365 days of exactly 24 hours each, with no provision for leap years or monkey business with 23/25 hour days (much less leap seconds!). But since the main work of this module is approximation, that shouldn't be a great problem for most purposes. SEE ALSO
Date::Interval, which is similarly named, but does something rather different. Star Trek: The Next Generation (1987-1994), where the character Data would express time durations like "1 year, 20 days, 22 hours, 59 minutes, and 35 seconds" instead of rounding to "1 year and 21 days". This is because no-one ever told him to use Time::Duration. COPYRIGHT AND DISCLAIMER
Copyright 2006, Sean M. Burke "sburke@cpan.org", all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. AUTHOR
Current maintainer Avi Finkel, "avi@finkel.org"; Original author Sean M. Burke, "sburke@cpan.org" perl v5.12.1 2007-08-19 Duration(3)
All times are GMT -4. The time now is 01:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy