Sponsored Content
Top Forums Shell Programming and Scripting Adding date and time to file name Post 302471756 by frans on Monday 15th of November 2010 03:27:53 AM
Old 11-15-2010
Something like
bash code:
  1. #!/bin/bash
  2. D=$(date +%d-%m-%Y)
  3. for F in *
  4. do
  5.    Dot="${F//[^\.]/}" # this removes anything but a dot
  6.    if [ -n "$Dot" ]; then
  7.       mv "$F" "${F%.*}-$D.${F##*.}"
  8.    else
  9.       mv "$F" "$F-$D"
  10.    fi
  11. done
Note: I put quotes around filenames to avoid problems with spaces in them.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Processing a log file based on date/time input and the date/time on the log file

Hi, I'm trying to accomplish the following and would like some suggestions or possible bash script examples that may work I have a directory that has a list of log files that's periodically dumped from a script that is crontab that are rotated 4 generations. There will be a time stamp that is... (4 Replies)
Discussion started by: primp
4 Replies

2. Shell Programming and Scripting

problem with displaying date and adding time

Hi, I have a log file with contents like 81.49.74.131 - - 81.49.74.131 - - 116.112.52.31 - - 116.112.52.31 - - I need an output like this 81.49.74.131 14/Sep/2008 Time duration: 00:06:00 116.112.52.31 15/Sep/2008 Time duration: 00:00:01 Please anyone suggest a script for this.... (1 Reply)
Discussion started by: FuncMx
1 Replies

3. UNIX for Dummies Questions & Answers

Adding date and time to a log file

Morning all Im hoping you can help me. We have a nice new oracle server :( and are needing to move some files around for EDI and BACS. The server runs windows but has an app called MKS toolkit installed which give unix commands. (Needed for the oracle stuff) I have had a go using dos commands... (2 Replies)
Discussion started by: ltodd2
2 Replies

4. UNIX for Dummies Questions & Answers

adding date to a file during FTP

I have a very basic question here. I have to FTP a file from a AIX unix box to a windows server. But during that I have to rename the file. For example: I have to FTP a file called ORDER.TXT from unix and it should go as ORDER_20090101.TXT on to the windows server. It is not possible to... (5 Replies)
Discussion started by: vara32
5 Replies

5. UNIX for Dummies Questions & Answers

Adding Date & time stamps to filename

I need to edit the file name with date and time while writing the script. please help. (1 Reply)
Discussion started by: manish.s
1 Replies

6. Shell Programming and Scripting

adding a date to the last of each file name

i have some files in my directory....wit names say aaa, bbb, ccc,,,,, i want to make loop so that for each file name,,,,,,a sysdate should be appended in the end.........and the files should look like aaa_20100331 i knw date can be appended as `date +"%Y%m%d"` but m nt able to make a loop. ... (2 Replies)
Discussion started by: amitpta
2 Replies

7. UNIX for Dummies Questions & Answers

[Solved] Adding time stamp to file name

I have the awk awk -F\* '$1=="ST",$1=="SE"{if($1=="ST"){close(f);f="sample" ++i} ; $1=$1; print>f}' OFS=\| <filename> How to add the time stamp to the file name mentioned as "sample" Please view this code tag video for how to use code tags when posting code and data. (6 Replies)
Discussion started by: atlantis_yy
6 Replies

8. UNIX for Dummies Questions & Answers

Adding hours and minutes to current date (Only to date not to time)

Hi, I want to add some hours and minutes to the current date. For example, if the current date is "July 16, 2012 15:20", i want to add 5 hours 30 minutes to "July 16, 2012 00:00" not to "July 16, 2012 15:20". Please help. Thanks! (4 Replies)
Discussion started by: manojgarg
4 Replies

9. Shell Programming and Scripting

Adding date to file

I want this: 0.0230769,0.407692,0.307692,0,0.1,1.4,1,0,ADD DATE HERE, im getting this: 11/02/12 0.00192308,0.0269231,0.0192308,0,0.1,1.4,1,0, my script: #!/bin/ksh DIR=/export/home/yani_m/scripts/scrip_out_put/ DIR2=/export/home/yani_m/scripts/scrip_out_put/calc/ Date=$1... (1 Reply)
Discussion started by: LucyYani
1 Replies

10. Shell Programming and Scripting

Adding time to date time in UNIX shell scipting

I needed some help in adding a duration (in seconds) to a start time (in hhmmss format) and a start date (in mmddyy format) in order to get an end date and end time. The concept of a leap year is also to be considered while incrementing the day. The code/ function that I have formed so far is as... (3 Replies)
Discussion started by: codehelp04
3 Replies
Graph::Reader::Dot(3pm) 				User Contributed Perl Documentation				   Graph::Reader::Dot(3pm)

NAME
Graph::Reader::Dot - class for reading a Graph instance from Dot format SYNOPSIS
use Graph::Reader::Dot; use Graph; $reader = Graph::Reader::Dot->new(); $graph = $reader->read_graph('mygraph.dot'); DESCRIPTION
Graph::Reader::Dot is a class for reading in a directed graph in the file format used by the dot tool (part of the AT+T graphviz package). Graph::Reader::Dot is a subclass of Graph::Reader, which defines the generic interface for Graph reader classes. METHODS AND CONFIGURATION
"new()" Constructor - generate a new reader instance. $reader = Graph::Reader::Dot->new(); This doesn't take any arguments. "read_graph()" Read a graph from a file: $graph = $reader->read_graph( $file ); The $file argument can be either a filename or a filehandle of a previously opened file. $Graph::Reader::Dot::UseNodeAttr Controls, if implicit node attributes given by the dot directive "node[]" will be merged into (new) nodes. Setting it to 0 or "undef" (default) will not disable this feature. Setting it to any other value will enable this feature. $Graph::Reader::Dot::UseEdgeAttr Controls, if implicit edge attributes given by the dot directive "edge[]" will be merged into edges. Setting it to 0 or "undef" (default) will not disable this feature. Setting it to any other value will enable this feature. RESTRICTIONS
o Default (graph) attributes in subgraphs (i.e. inside "{}") are not processed. o Sub nodes as used by dot's "record" node shape are supported. o Undirected graphs will be treated as directed graphs. This means that the "--" edge operator works as the "->" edge operator. o Be aware that you are loosing scope information on writing back the graph. o Multiple "node[]" or "edge[]" statements in the same scope are not correctly supported. SEE ALSO
http://www.graphviz.org/ The home page for the AT+T graphviz toolkit that includes the dot tool. Graph::Reader The base class for Graph::Reader::Dot. Graph::Writer::Dot Used to serialise a Graph instance in Dot format. Graph Jarkko Hietaniemi's classes for representing directed graphs. Parse::Yapp Another base class for Graph::Reader::Dot. The Parse::Yapp module comes with the following copyright notice: The Parse::Yapp module and its related modules and shell scripts are copyright (c) 1998-1999 Francois Desarmenien, France. All rights reserved. You may use and distribute them under the terms of either the GNU General Public License or the Artistic License, as specified in the Perl README file. If you use the "standalone parser" option so people don't need to install Parse::Yapp on their systems in order to run you software, this copyright noticed should be included in your software copyright too, and the copyright notice in the embedded driver should be left untouched. AUTHOR
Mark A. Hillebrand <mah@wjpserver.cs.uni-sb.de> COPYRIGHT
Copyright (c) 2001 by Mark A. Hillebrand. All rights reserved. This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.14.2 2012-02-12 Graph::Reader::Dot(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