Need help to write a shell script ASAP


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Need help to write a shell script ASAP
# 1  
Old 05-05-2011
Need help to write a shell script ASAP

Hi,

1) Need help to write script in KSH to detect a duplicate file.
2) The original file needs to be moved from current path to a different path
3) The duplicate file should continue to stay in the same path.

Exact file names & duplicate file names are given below. Please help me at the earliest.


drwxrwxrwx 4 tcpadmin tcpadmin 5120 Apr 20 10:00 tmp
-rw-r--r-- 1 bpa develop 27068910 May 3 00:07 042728840_scpm-042728840-user_problem_summary-_20110503_120728372.txt
-rw-r--r-- 1 bpa develop 7020298 May 3 00:14 042728840_scpm-042728840-supplier_cycle_time-_20110503_121412886.txt
-rw-r--r-- 1 bpa develop 54866475 May 3 00:14 042728840_scpm-042728840-ppff_collab-_20110503_121449501.txt
-rw-r--r-- 1 bpa develop 35422167 May 3 00:17 042728840_scpm-042728840-collab_attribute-_20110503_1217397.txt
drwxr-xr-x 2 bpa develop 24576 May 3 21:25 backup

-rw-r--r-- 1 bpa develop 27075335 May 4 00:01 042728840_scpm-042728840-user_problem_summary-_20110504_120104176.txt
-rw-r--r-- 1 bpa develop 8007433 May 4 00:05 042728840_scpm-042728840-supplier_cycle_time-_20110504_120556132.txt
-rw-r--r-- 1 bpa develop 54866475 May 4 00:06 042728840_scpm-042728840-ppff_collab-_20110504_120629727.txt
-rw-r--r-- 1 bpa develop 35422167 May 4 00:09 042728840_scpm-042728840-collab_attribute-_20110504_120915727.txt
# 2  
Old 05-05-2011
Before help I want to know
1) Need help to write script in KSH to detect a duplicate file.
Question: duplicate file name in two different directories or duplicate content in two different file name.
# 3  
Old 05-05-2011
Reply

In same directory only. Please observe the example.....
# 4  
Old 05-05-2011
Duplicate file in term by the name of the file or the content of the file?

---------- Post updated at 01:39 PM ---------- Previous update was at 01:38 PM ----------

As you said duplicate files in the same directory so you must be saying that there are two files with same content. But how do you find which one as orignal and which one is duplicate?
# 5  
Old 05-05-2011
Need details

could you give some differences between original & duplicate files,

I mean, gimme some parameterised differences,

is we need to move the old files ( i.e. which is created first.) to other directory. and need to retain the latest file in the current directory.

Thanks
# 6  
Old 05-05-2011
Quote:
Originally Posted by bhagya3001
In same directory only. Please observe the example.....
Are you saying file names are same in a directroy? Is it possible? Pls run
Code:
ls -ltra

on your working directory and point us having two files on same name.
# 7  
Old 05-05-2011
a=0
for file in $path_Files_located/*
do
a=`echo $file | cut -c 1-60`
find $path_Files_located/* -type f ! -name $file > temp.txt
b=`/bin/grep $a temp.txt | wc -l`
if [ $b -gt 1 ]; then
/bin/mv $file $new_path_of_backup_Files/
fi
done


# tune the above code for good performance
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Please help me to write the shell script

Please help me to write the shell script AC|NAME|STATE|MAXVALUE|MINVALUE---------heading 111|UMA|ODISHA|123,00.00|54.00 111|UMA|ODISHA|124,00.00|25.00 111|UMA|ODISHA|114,00.00|58.00 111|UMA|ODISHA|104,00.00|00.00 111|UMA|ODISHA|194,00.00|19.00 111|UMA|ODISHA|184,00.00|64.00... (5 Replies)
Discussion started by: alokjyotibal
5 Replies

2. Shell Programming and Scripting

How to write config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

3. UNIX for Dummies Questions & Answers

How to write Config shell script to pass variables in master shell script?

Dear Unix gurus, We have a config shell script file which has 30 variables which needs to be passed to master unix shell script that invokes oracle database sessions. So those 30 variables need to go through the database sessions (They are inputs) via a shell script. one of the variable name... (1 Reply)
Discussion started by: dba1981
1 Replies

4. Shell Programming and Scripting

Need to write a shell script

Hi, I need some help to write a script i need to write script that will count the no of logs generated for the day and specify the logfiles names which is not generated for the day. Default no of log generate per day is 29 if less than 29 logs generated it should specify the perticular logfile... (7 Replies)
Discussion started by: mail.chiranjit
7 Replies

5. Shell Programming and Scripting

NEED HELP FROM SHELL EXPERTS ASAP ..Compare of two files

I have seen the old forums before posting this thread...I did not find the designated answer for my shell script... I am novice in shell programming: Can some one help on how i can loop with in the loop when comparing two files... I need to compare ID in File1 with IDs in File2...If the ID... (1 Reply)
Discussion started by: rspotula
1 Replies

6. Shell Programming and Scripting

how to write shell script

Hi , i need to write a script like this In 1.sh ./test.sh wait(5sec) send ctrl+C to server ./testxxxx.sh first i need invoke test.sh from 1.sh , after wating for some time i need to close the test.sh script & i need to start new script i tried to invoke script... (2 Replies)
Discussion started by: pvr_satya
2 Replies

7. Shell Programming and Scripting

Need to Write Shell Script based off of this shell command

I'm trying to read a bunch of log files and output the lines that contain particular strings. To accomplish this, I've been running the following from the command line: find . -name "*" | xargs grep " " | grep " " > output.txt Two grep statements are needed in case I'm looking for a... (3 Replies)
Discussion started by: Rally_Point
3 Replies

8. Shell Programming and Scripting

I need to write a shell script.

Hi Guys, I need to write a shell script, to which I have getting results from CPU and Memory Utilization. This is to generate automatically through Shell script by running cron job. Is it possible to write it. I am new to this shell scripting. Can you please help me on this ASAP. ... (6 Replies)
Discussion started by: lakshmanrk
6 Replies

9. Shell Programming and Scripting

need help to write shell script

. I wrote shell script with help to extract data and generate report . I need help to modify that in sub section . Currently I am generating the report in this format Version Name Host Total Number of Fails 10 Animator 45 10 Krachel ... (0 Replies)
Discussion started by: getdpg
0 Replies

10. Shell Programming and Scripting

Need rm script help ASAP

I need your expertise anyone. I'm trying to remove part of a id # in a script. Reason, the part of the id is a underscore that is making my life impossible. I simply cannot handle all the requests and modify every single one in vi or edt. So I wanted to modify the script.. For example ... (12 Replies)
Discussion started by: simon2000
12 Replies
Login or Register to Ask a Question