Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Insert date/time within a filename Post 88595 by cooperman on Monday 7th of November 2005 06:14:36 AM
Old 11-07-2005
Insert date/time within a filename

Hi Guys,

I need to script the renaming of files as followins:

files:

firstjd
secondjo
thirdjv

My script needs to insert the date/time infront of the last 2 characters of the filenames above, any ideas greatly received Smilie
the letters before the last 2 characters could change, I'm only interested in inserting date/time in front of the last 2 characters, whatever they maybe.

Many thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Renaming files to have date/time in filename

I have a program that will export my data to a single file, but it assigns a file name that is overridden every time I run the program. I need to change the file name to have a sequential number in the filename. How do I rename a file so that the filename contains the system date and time. I want... (5 Replies)
Discussion started by: wayneb
5 Replies

2. Shell Programming and Scripting

Insert Time and Date Stamp

I have a directory with following files in it ABC.000.DAT ABC.001.DAT ABC.002.DAT ABC.003.DAT I want to insert time and date stamp in file names like ABC.000.YYYYMMDDHHMM.DAT I able to insert the time and date stamp at the end of filename Kindly help (1 Reply)
Discussion started by: aajmani
1 Replies

3. UNIX for Advanced & Expert Users

find formatted filename with date time

Hi, I operate and use HF radars along the California coast for ocean surface currents. The devices use Mac OS as the control and logging software. The software generates thousands of files a week and while I've used PERL in the past to solve the problems of finding files I come to realize some... (6 Replies)
Discussion started by: dpath2o
6 Replies

4. UNIX for Dummies Questions & Answers

Shell Scripts - Append a filename with date and time....

Hello, I need to create a shell script that appends a filename to create a name with the date and time appended that is guaranteed to not exist. That is, the script insures you will not overwrite a file with the same name. I am lost with this one. I know I need to use date but after that I am... (3 Replies)
Discussion started by: citizencro
3 Replies

5. Shell Programming and Scripting

append a filename with system date and time

Hi, There are similar kind of posts, but none seems like working for me. Please correct me if I'm wrong. I need append/rename file abc.txt with file processed date and time like abc_systemdatetimestamp.txt and move it to different folder. for example I have /source/data/abc.txt ... (1 Reply)
Discussion started by: amsn08
1 Replies

6. Shell Programming and Scripting

Insert date/time in reoccurring blocks of lines

Hi folks, I have a little problem, that is kinda bugging me :( ... I have a logfile, that looks kinda "crippled" in the raw format ... So far, I've managed, to get it in a format like this: PRI_PTA01,2W,30,30,0,0,0,0,0,0,0,0,0,0,0,0... (5 Replies)
Discussion started by: whizzler
5 Replies

7. Shell Programming and Scripting

Insert date/time header at top of file

I'm trying to take mrt output and put it at the top of a file along with the date and time. I was able to do it at the bottom of the file with the following printf "********** $(date) **********\n\n" >> $OUTPUT_PATH/$HOSTNAME mtr -r -w -c 10 $HOSTADDRESS >> $OUTPUT_PATH/$HOSTNAME printf... (2 Replies)
Discussion started by: kramer65
2 Replies

8. Shell Programming and Scripting

Validate date and time in filename by awk

hi i want to validate the date and time in filename filename : mohan.moh.ccyymmdd.ccyymmdd.hhmmss.txt mohan_moh.20151222.20151222.122442.txt i want code that check that date given in filename 20151222 in this format ccyymmdd else it mark file is not valid used in my OS detail is AIX 6... (12 Replies)
Discussion started by: MOHANP12
12 Replies

9. UNIX for Beginners Questions & Answers

How to extract date and time from filename?

Hi, I'm totally new in sell script and working with a shell code. I want to extract the date and time from the filenames. The filenames are different but all of them begins with WI_ SCOPE_: WI_SCOPE_DATA_CHANGE_2017-09-12_15-30-40.txt WI_SCOPE_BACK_COMPLETE_QUEUE_2017-09-12_15-31-40.txt... (5 Replies)
Discussion started by: Home
5 Replies

10. UNIX for Beginners Questions & Answers

Extract date and time part from filename

Hi, I am facing one scenario in which I need to extract exact position of date and time from the name of the files. For example, Below is the record in which I need to extract position of YYYYMMDD,HHMISS and YYMMDD. Date and time variables can come more than once. I need to use these position... (13 Replies)
Discussion started by: Prathmesh
13 Replies
ar(1)							      General Commands Manual							     ar(1)

Name
       ar - archive and library maintainer

Syntax
       ar option [ posname ] archive file ...

Description
       The archiver ar maintains groups of files as a single archive file.  This utility is generally used to create and update library files that
       the link editor uses; however, you can use the archiver for other similar purposes.  This version uses a portable ASCII-format archive that
       you can use on various machines that run UNIX.  If you have an archive that uses an older format, see

Options
       This  section  describes the options and suboptions that you can use with the ar utility.  Suboptions must be specified with options.  Fol-
       lowing is a list and description of the options:

       d      Deletes the specified files from the archive file.

       r      Replaces the specified files in the archive file.  If you use the suboption u with r, the archiver only replaces	those  files  that
	      have  last-modified  dates later than the archive files.	If you use a positioning character (from the set abi) you must specify the
	      posname argument to tell the archiver to put the new files after (a) or before (b or i).	Otherwise, the archiver puts new files	at
	      the end of the archive.

       q      Appends  the specified files to the end of the archive file.  The archiver does not accept suboption positioning characters with the
	      q option.  It also does not check whether the files you want to add already exist in the archive.  Use the q option  only  to  avoid
	      quadratic behavior when you create a large archive piece by piece.

       t      Prints  a  table of contents for the files in the archive file.  If you do not specify any filenames, the archiver builds a table of
	      contents for all files.  If you specify filenames, the archiver builds a table of contents only for those files.

       p      Prints the specified files from the archive.

       m      Moves the specified files to the end of the archive.  If you specify a positioning character, you must also specify the posname  (as
	      in option r) to tell the archiver where to move the files.

       x      Extracts	the  specified	files  from  the  archive.  If you do not specify any filenames, the archiver extracts all files.  When it
	      extracts files, the archiver does not change any file.  Normally, the last-modified date for each extracted file shows the date when
	      someone extracted it; however, when you use o, the archiver resets the last-modified date to the date recorded in the archive.

       s      Makes a symbol definition (symdef file) as the first file of an archive.	This file contains a hash table of ranlib structures and a
	      corresponding string table. The symdef file's name is based on the byte ordering of the hash table and  the  byte  ordering  of  the
	      file's target machine.  Files must be consistent in their target byte ordering before the archiver can create a symdef file.  If you
	      change the archive contents, the symdef file becomes obsolete because the archive file's	name  changes.	 If  you  specify  s,  the
	      archiver	creates the symdef file as its last action before finishing execution.	You must specify at least one other archive option
	      (m, p, q, r, or t) when you use the s option.  For UMIPS-V, archives include member objects based on  the  definition  of  a  common
	      object only.  For UMIPS-BSD, they define the common object, but do not include the object.

       v      Gives  a	file-by-file description as the archiver makes a new archive file from an old archive and its constituent files.  When you
	      use this option with t, the archiver lists all information about the files in the archive.  When you use this  option  with  p,  the
	      archiver precedes each file with a name.

       c      Suppresses  the  normal message that the archiver prints when it creates the specified archive file.  Normally, the archiver creates
	      the specified archiver file when it needs to.

       l      Places temporary files in the local directory.  If the l option is not used then the value of the  environment  symbol,  TMPDIR,	is
	      used  as the directory for temporary files.  If TMPDIR is not defined or if the directory it references is not writable then /tmp is
	      used.

       The suboptions do these things:

       a      Specifies that the file goes after the existing file (posname).  Use this suboption with the m or r options.

       b      Specifies that the file goes before the existing file (posname).	Use this suboption with the m or r options.

       i      Specifies that the file goes before the existing file (posname).	Use this suboption with the m or r options.

       o      Forces a newly created file to have the last-modified date that it had before it was extracted from the archive.	Use this suboption
	      with the x option.

       u      Prevents	the archiver from replacing an existing file unless the replacement is newer than the existing file.  This option uses the
	      UNIX system last modified date for this comparison.  Use this suboption with the r option.

Restrictions
       If you specify the same file twice in an argument list, it can appear twice in the archive file.

       The o option does not change the last-modified date of a file unless you own the extracted file or you are the superuser.

       This command truncates filenames to 15 characters.

Files
       /tmp/v*	 temporaries

See Also
       lorder(1), ld(1), odump(1), ranlib(1), ranhash(3x), ar(5), arcv(8)

								       RISC								     ar(1)
All times are GMT -4. The time now is 11:21 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy