If it's only 2 files, why not doing that manually?
Variant 1:
Variant 2 (rename + move at the same time):
Anyways, below you will find some code to do that automatically (utilizing variant 2).
With help from stat from GNU coreutils:
With help from find from GNU findutils:
If you run the first approach and the output looks reasonable, removeecho from the code to perform the actual renaming/moving process.
If you run the second approach and the output looks reasonable, add | sh at the end of that long find command to perform the actual renaming/moving process.
Important: No matter which solution you might use, make sure you change /path/to/another/bkp/dir/ accordingly to reflect the your real backup directory.
I'm trying to create a bash function that will allow me to rename a file name emails.txt to last monday's date
renem ()
{
d=`date -d last-monday`
mv ~/emails.txt ~/myemails/$d
}
but i en up wit this error any suggestion
mv: target `2014' is not a directory (3 Replies)
hello,
can someone please suggest a script to rename a file that was generated today and filename that being generated daily starts with date, its a xml file.
here is example.
# find . -type f -mtime -1
./20130529_4995733057260357019.xml
#
this finename should be renamed to this format.... (6 Replies)
To delete log files content older than 30 days and append the lastest date log file date in the respective logs
I want to write a shell script that deletes all log files content older than 30 days and append the lastest log file date in the respective logs
This is my script
cd... (2 Replies)
Hi!
Please see our current script:
#!/usr/bin/ksh
if (egrep "This string is found in the log" /a01/bpm.log)
then
mailx -s "Error from log" me@email.com, him@email.com </a01/bpm.log
fi
To the above existing script, we need to add the following change:
1) After finding the string,... (7 Replies)
Hi Can anyone assist me, I am trying to compate the size of a logfile to a maximum size 1000 and delete if exceeds the limit.
The problem I am getting is the command not found for the line
if ( $LOGNAME_SIZE >= $MAXSIZE); then
Appreciate your response.
Script:
LOGDIR="/home/... (6 Replies)
Hi
I am trying to create a simple function that implements log rotation
rotatelogs () {
file_name=$1
archive_dir=$2
retention_period=$3
find $archive_dir -name $file_name -mtime +$retention_period -exec rm -f {} \;
}
Issue i am facing is the file_name would be something like my... (3 Replies)
I am trying to rename files based on the created/born date of the file. I Have a total of 4000 files that i am trying to do this with and would like it to be log_yyyymmddhh.gz right now the files are maillog.???.gz.
Can anyone point me in the right direction of how to get this done via scipt?
... (4 Replies)
Hi guys,
I've googled this quite a bit, and tried searching on these forums, but haven't found a solution to my problem. I wanted to inquire about AIX's audit subsystem - more specifically, how to rotate its log file.
So far I've been able to find how to rotate AIX syslog log files, and I... (2 Replies)
File.jpg
I want to copy and rename this as 2008-12-02.jpg
I tried this copy File.jpg date '%y-%m-%d-%H:%M:%S'.jpg
This doesnt work.... what do i do? (1 Reply)
Hi, I am trying to come with one line command which will rename a file to have Date (MMDDYYYY) and Line Count in the file. Any lead will be appreciated
rgds
bmk (2 Replies)