Sponsored Content
Top Forums Shell Programming and Scripting How to append timestamp in the filenames using find? Post 302832075 by bobbygsk on Friday 12th of July 2013 04:32:30 PM
Old 07-12-2013
How to append timestamp in the filenames using find?

Hi,

How to change the filenames with timestamp in sub folders
I have the following code to select the records.

Code:
find . -type f -name '*pqr*' -ctime 1 -print

The following is the example
Code:
app_root_dir="/`echo $ScriptDir | cut -d'/' -f2`"

$app_root_dir/../BadFiles directory
uvw.bad
xyz.bad
mno.bad

$app_root_dir/../TgtFiles directory
uvw.out
xyz.out
mno.out

I like to rename those files with ..
Code:
$app_root_dir/../BadFiles directory
uvw.20130712163028.bad
xyz.20130712163028.bad
mno.20130712163028.bad

$app_root_dir/../TgtFiles directory
uvw.20130712163028.out
xyz.20130712163028.out
mno.20130712163028.out

I already have dt=`date +%Y%m%d%H%M%S`


I have to rename the filenames as in each environment my path(folder name) differs.

Appreciate advice on other commands/options to use.

Last edited by Scott; 07-15-2013 at 04:31 PM.. Reason: Code tags not quote tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

find lowercase filenames

How do I write the command to find all files with any lower case letters in the filename? I have tried find . -name *\(a-z\) and a lot of combinations like that, without success. thanks JP:confused: (4 Replies)
Discussion started by: jpprial
4 Replies

2. Shell Programming and Scripting

find filenames like unix commands

Hi, I need to write a small script to search in some specific directories to check if any file is present with a unix command name... Means if the directory contains any files like cat, vi, grep, find etc i need to list those files into a file. Please help Thanks, D (6 Replies)
Discussion started by: deepakgang
6 Replies

3. Solaris

feeding filenames to find command

Hi, I am having set of files whose names are stored in a file say "filelist.txt" Now, I want to find all files contained in "filelist.txt" from my parent directory. Is there any way to let find command understand "filelist.txt" just like we have option -f in awk. I donot want to run a... (4 Replies)
Discussion started by: sanjay1979
4 Replies

4. UNIX for Dummies Questions & Answers

Append file with grep output but add timestamp?

I've setup a cron job that greps a file every five minutes and then writes (appends) the grep output/result to another file: grep "monkey" zoo.log | tail -1 >> cron-zoo-log Is there any way I can add the date and time (timestamp) to the cron-zoo-log file for each time a new line was added? ... (12 Replies)
Discussion started by: Sepia
12 Replies

5. Shell Programming and Scripting

awk help with find command and filenames with spaces

I have the following code: find /usr/local/test5 -type f -mtime +30 -exec ls -l {} \; | awk '{print $5, $6, $7, $8, $9}' I have this as output: 14 Aug 12 00:00 /usr/local/test5/file1 14 Aug 12 00:00 /usr/local/test5/lastname, The bolded part is where I run into trouble. The actual... (4 Replies)
Discussion started by: streetfighter2
4 Replies

6. Shell Programming and Scripting

Print and Append the matching filenames

Hi, I want to check all files in a folder for some specific start string and append all matching filenames with _1, _2 .... for each file found in the directory. But, $file below gives me all details of the files like access permissions, owner and filename etc. I just want all the filenames... (3 Replies)
Discussion started by: chetancrsp18
3 Replies

7. UNIX for Dummies Questions & Answers

find & remove characters in filenames

I have a group of files in different directories with characters such as " ? : in the file names. How do I find these files and remove these characters on mass? Thanks (19 Replies)
Discussion started by: barrydocks
19 Replies

8. Shell Programming and Scripting

Use sed to append text to filenames if text not already present

I have some html with hrefs that contain local links to pdf filenames. These filenames should have standardised names, i.e. there should be a label prior to the ".pdf" filename suffix. There can be many of these links on a single line of text and some may already have the label. For example ... (13 Replies)
Discussion started by: adb
13 Replies

9. Shell Programming and Scripting

Get filenames without timestamp

Hi, In my previous post I looked for timestamp to be added to the filename https://www.unix.com/shell-programming-scripting/230603-how-append-timestamp-filenames-using-find.html Now how do I select those files that do not have timestamp in the filenames. I tried the following. My file has... (3 Replies)
Discussion started by: bobbygsk
3 Replies

10. Shell Programming and Scripting

Append timestamp create .trg file for all content of an unzipped archive

Hi, I have a test.zip archive that contains test.zip --> (file_1.txt, file_2.txt , file_3.txt) I need to unzip the file like this, file_1_timestamp.txt file_1_timestamp.trg file_2_timestamp.txt file_2_timestamp.trg file_3_timestamp.txt file_3_timestamp.trg Could you please let me know... (7 Replies)
Discussion started by: Shandel
7 Replies
pam_timestamp_check(8)					   System Administrator's Manual				    pam_timestamp_check(8)

NAME
pam_timestamp_check - check or clear authentication timestamps SYNOPSIS
pam_timestamp [[-d]|[-k]] [target_user] DESCRIPTION
With no arguments, pam_timestamp_check will check to see if the default timestamp is valid, or optionally remove it. OPTIONS
-k instead of checking the validity of a timestamp, remove it. This is analogous to sudo's -k option. -d Instead of returning validity using an exit status, loop indefinitely, polling regularly and printing the status on standard output. target_user The default behavior of pam_timestamp_check checks or removes timestamps generated by pam_timestamp when the user authenticates as herself. When the user authenticates as a different user, the name of the timestamp file changes to accomodate this. DIAGNOSTICS
When checking if a timestamp is valid, pam_timestamp_check returns an exit code of 0 for success and > 0 on error: 2: binary is not setuid-root 3: invalid invocation 4: user unknown 5: permissions error 6: invalid controlling tty 7: other error SEE ALSO
pam_timestamp(8) BUGS
Let's hope not, but if you find any, please email the author. AUTHOR
Nalin Dahyabhai <nalin@redhat.com> Red Hat Linux 2002/05/23 pam_timestamp_check(8)
All times are GMT -4. The time now is 11:15 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy