to check redundant file names


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting to check redundant file names
# 1  
Old 02-02-2004
Data to check redundant file names

hi
i have a very simple problem
iam moving files from download to archive folder
but before such a transfer want to make sure no two file of same
are present in my download directory
how to check for redundant file names
i thought of using WC but it counts inside the file (lines and characters)
# 2  
Old 02-02-2004
I don't understand... you can't have two files in the same directory with the same name.

Do you want to make sure there isn't a file in the archive folder with the same name as the file you're moving out of the download folder?
# 3  
Old 02-02-2004
Bug it should be archive not download

hi oombra
first of all sorry for the confusion
yes indeed iam checking files in archive folder

actually iam moving files from download dir to archive folder
after inserting the date time stamp. now i want to make sure that
there are no files with same name and same date(time may differ)
in the archive folder

i want to do it cause in that case i want to use the most recent file
# 4  
Old 02-02-2004
If you are using a shell script, simply test for the existance
of the file prior to moving it to the archive directory.

[ -e $file ] && {
echo "file already exists"
}

- F
# 5  
Old 02-09-2004
A different approach to this problem:

If you named your file correctly when you move it e.g. in the format

FILE_YYYYMMDD_hhmmss

where YYYY = year
MM = month number
DD = day number
hh = hours
mm = minutes
ss = seconds

Then you could move all files to the archive directory. When you want to process the most recent file do something like:

PROCESS_FILE=`ls dir FILE_* | sort -r | head -n 1`

If necessary you may remove unneccessary files from the archive directory by using the find command:

find $ARCHIVE_DIR -mtime 3 -exec rm -f {} \;

to remove files more than 3 days old.

Regards

MBB
# 6  
Old 02-09-2004
i know the problem you are haveing. because i had it.

1) i archive by day.
2) most files have a time stamp to the sec. (still dosnet help)
3) i use a microsec at the end of the file name. (now 1 in a million chance of haveing the same name.

so if you test the existance of the current filename in your archive dir. and move it to the archive dir w/ a microsec at the end of it you will be all good.

this is the code for a 6 digit microsec it is in c.

Code:
#include <stdlib.h>
#include <sys/time.h>
main()
{
     struct timeval tv;
     struct timezone tz;
     struct tm *tm;
     gettimeofday(&tv, &tz);
     tm=localtime(&tv.tv_sec);
        printf("%06d\n", tv.tv_usec);
     exit(0);
}

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Reduce redundant file

Dear All, I have to reduce the redundancy of a file that is like this: a b 0 a c 0 a f 1 b a 1 b a 0 b c 1 d f 0 g h 1 f d 1 Basically, this file describe a network with relative nodes and edges. The nodes are the different letters and the edges are represented by the numbers (in... (7 Replies)
Discussion started by: giuliangiuseppe
7 Replies

2. Shell Programming and Scripting

Exclude certain file names while selectingData files coming in different names in a file name called

Data files coming in different names in a file name called process.txt. 1. shipments_yyyymmdd.gz 2 Order_yyyymmdd.gz 3. Invoice_yyyymmdd.gz 4. globalorder_yyyymmdd.gz The process needs to discard all the below files and only process two of the 4 file names available ... (1 Reply)
Discussion started by: dsravanam
1 Replies

3. Shell Programming and Scripting

Check for particular files and compare the file names

Hi, Below are the 2 files in directory /tmp: masterCSF242323.img indexCSF242323.img 1) I want to compare if both the number (242323) are same in both the files. If they are same print - Files matching, else print files do not match. 2) Also if only index file is present in that... (7 Replies)
Discussion started by: apatil65
7 Replies

4. Shell Programming and Scripting

check if the insert statement is using column names

Hi, Input- a file comtaining a procedure or function with various statements in that one of the statement would be insert into table1 (a,b,c) values (1,2,3) ourput required true if insert statement is using column name (a,b,c) else false. Please suggest (8 Replies)
Discussion started by: manasa_vs
8 Replies

5. Shell Programming and Scripting

Find redundant text in a file

I want to find which pattern or strings have occurred more than one time so that I can remove unnecessary redundancy. For example: If I have the sentence: A quick brown brown fox jumps jumps jumps over the lazy dog in a file, then I want to know that 1. the word "brown" has... (7 Replies)
Discussion started by: hbar
7 Replies

6. UNIX for Dummies Questions & Answers

Deleting all rows that contain redundant information

My input file looks like this: 1 rs4040617 0.08356 1 rs4040617 0.06799 1 rs2977612 0.07948 1 rs2977612 0.07882 1 rs2977612 0.07783 1 rs2977612 0.08142 1 rs2977612 0.07716 1 rs2977612 0.08356 1 rs2977612 0.06799 1 rs2980300 0.08356 1 rs2980300 0.08142 I want to delete all rows that... (1 Reply)
Discussion started by: evelibertine
1 Replies

7. Shell Programming and Scripting

Searching for file names in a directory while ignoring certain file names

Sun Solaris Unix Question Haven't been able to find any solution for this situation. Let's just say the file names listed below exist in a directory. I want the find command to find all files in this directory but at the same time I want to eliminate certain file names or files with certain... (2 Replies)
Discussion started by: 2reperry
2 Replies

8. Filesystems, Disks and Memory

ZFS Raidz not redundant?

My ZFS on debian media server just died in a power outage, the zpool status shows this: NAME STATE READ WRITE CKSUM tank UNAVAIL 0 0 0 insufficient replicas raidz1 UNAVAIL 0 0 0 corrupted data sda ONLINE 0 0 0 sdb ONLINE 0 0 0 sdf ONLINE 0 0 0 sdh ONLINE 0 0 0 sdi ONLINE 0 0 0 sdk ONLINE 0... (2 Replies)
Discussion started by: mastersarg
2 Replies

9. UNIX for Advanced & Expert Users

Recursively check the file/dir names

Hi, ' recgrep find . | xargs grep ' is used to scan the contents recursively. I have a different requirement. I need to scan just the names and check for a pattern and display with fullpath. Is that already available? Closest that I am trying is 'ls -R | grep pattern' Here I would get multiple... (1 Reply)
Discussion started by: eagercyber
1 Replies

10. UNIX for Dummies Questions & Answers

Question is redundant but please advice

I am really really new to Unix. I'm lost with so many books around for different shell. I'm thinking of taking a course on Operating Systems but it contains a lot of Unix programming I think. For example, someone was talking about a "which" command. But I wasn't able to figure out what it does...... (10 Replies)
Discussion started by: Legend986
10 Replies
Login or Register to Ask a Question