And if the number of files is 10 i.e date more than 10 days then delete last file and add latest file
If a new file abc.txt is moved on 07182011 the new file need to be added with date abc07182011.txt and if more than 10 days old file exists then delete
To count the number of files in the current directory, you can use "ls" (<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ls.html>) and "wc" (<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/wc.html>) as follows:
Then use "[" a.k.a. "test" (<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/test.html>) to see if the result is greater than or equal to 10.
And you can get the name of the oldest file using "ls" and "tail" (<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/tail.html>) as follows:
To get the date, use "date" (<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/date.html>). Something like this should be what you want:
And you can add the date to a file whose name ends in ".txt" using "sed" (<http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html>). For example:
I'm not sure exactly what you're trying to do, but hopefully this will help get you started.
Thanks . .. This will surely get me started. I am trying to take the backups for the past 10 days with the same file name and I need last ten days versions to be in the folder.
I have this code that works great ...
#!/bin/sh
for file in "$@"
do
ext=${file##*.}
base=${file%.*}
num=${base##*v}
zeroes=${num%%*}
num=${num#$zeroes} #remove leading zeros, or it uses octal
num=$((num+1))
base=${base%v*}
... (5 Replies)
Hi,
I need to get versioning of the branch name dynamically. can you please help us to achieve this functionality.
curl https://altrecmktg.com/artifactory/mediamarketing/release-2.0.1/altrec.tar
curl https://altrecmktg.com/artifactory/mediamarketing/release-2.0.2/altrec.tar
everytime... (5 Replies)
Hello Unix Shell Script Experts,
I have a script that would mask the columns in .csv file or .txt file.
First the script will untar the .zip files from Archive folder and processes into work folder and finally pushes the masked .csv files into Feed folder.
Two parameters are passed
... (5 Replies)
Hi ,
I am using SCO openserver realease 3.2 and tried to test versioning on a directory with undelete -s . The command executes well but it is not creating any versions of the files in it. I have also setted versioning options via filesystem and then remounted it but of ... (0 Replies)
Hi all,
I am new to shell scripting.
I have dbf file and I need to convert it into csv file.
OR, can i read the fields from a .dbf file and OR seprate the records in dbf file and put into .csv or txt.
Actually in the .dbf files I am getting , the numbers of fields may vary in very record and... (6 Replies)
A question that has come up repeatedly where I work from our former VMS guys is... "will any Linux filesystem ever support versioning like RMS did"? When they talk about versioning they really are talking about something that *I think* would involve having apps that support versioning. For... (7 Replies)
Dear Members,
Do you know any information about versioning a binary file. That means test.out 1.0.0, 1.0.1, 1.1.0, and so on. Can I manually edit version number (both major and minor) and revision number myself (how?) or any utility to set version number (which one?).
Best Regards,
Francesco (2 Replies)
Please correct me if I am wrong... Isnt the only difference between minor releases of Solaris, ex. 9/04 and 9/05, is the patche revs between them? If so, why does the /etc/release info stay static when patched? (4 Replies)