Trying to do multiple dir's and multiple file names etc.


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Trying to do multiple dir's and multiple file names etc.
# 1  
Old 02-17-2014
Trying to do multiple dir's and multiple file names etc.

What am I missing?

Code:
find: 0652-009 There is a missing conjunction
find: 0652-009 There is a missing conjunction
find: 0652-009 There is a missing conjunction
find: 0652-009 There is a missing conjunction
find: 0652-009 There is a missing conjunction
find: 0652-009 There is a missing conjunction
find: 0652-009 There is a missing conjunction


Code:
#!/bin/ksh
#set -x
file_path1="/cddata/bi/logs/21l/data/cdr/"
file_path2="/cddata/bi/crm_ose/"
file_path3="/logs/21l/data/cem/"
file_path4="/logs/21l/data/archive/ "
file_path6="/logs/21l/data/dual4g/"
file_path7="/logs/6rl/data/backups/"
file_path8="/logs/p7p/data/backups/"
file_path9="/cddata/bi/"
file_path10="/cddata/bi2/"
file_nm1="dat"
file_nm2="sp_teoco_dly"
file_nm3="cl_dualmode_201"
file_nm4="gz"
daytype1=1
daytype2=10
daytype3=30
daytype4=90
find $file_path1/*$file_nm1* -type f -mtime +$daytype2 -exec ls -l {} \; ~/>>cleanup.log
find $file_path2/*$file_nm1* -type f -mtime +$daytype1 -exec ls -l {} \; ~/>>cleanup.log
find $file_path3/*$file_nm1* -type f -mtime +$daytype2 -exec ls -l {} \; ~/>>cleanup.log
find $file_path4/*$file_nm2* -type f -mtime +$daytype3 -exec ls -l {} \; ~/>>cleanup.log
find $file_path6/*$file_nm3* -type f -mtime +$daytype3 -exec ls -l {} \; ~/>>cleanup.log
find $file_path7/*$file_nm4* -type f -mtime +$daytype3 -exec ls -l {} \; ~/>>cleanup.log
find $file_path8/*$file_nm4* -type f -mtime +$daytype3 -exec ls -l {} \; ~/>>cleanup.log

The ls -l will be replaced with an rm -f once I see if it's working.

Last edited by Scrutinizer; 02-17-2014 at 03:37 PM.. Reason: additional code tags
# 2  
Old 02-17-2014
You need double quotes around $file_path1/*$file_nm1* etc...
Code:
find "$file_path1/*$file_nm1*" ....

--
BTW it is more efficient to use -exec ls -l {} + instead of -exec ls -l {} \;

(This is because with the second option a separate sub process is started for each and every result that find finds. With the first option as many results are added to the list of arguments as max line length allows and the command is only executed once for every set of arguments.. )

Last edited by Scrutinizer; 02-18-2014 at 08:01 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 3  
Old 02-17-2014
Still not working, or maybe it means there aren't any files in there that age?
Code:
>cleanup.sh
find: 0652-019 The status on /cddata/bi/logs/21l/data/cdr/*dat is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.
find: 0652-019 The status on /cddata/bi/crm_ose/*dat is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.
find: 0652-019 The status on /logs/21l/data/cem/*dat is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.
find: 0652-019 The status on /logs/21l/data/archive/*sprint_teoco_dly* is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.
find: 0652-019 The status on /logs/21l/data/dual4g/*clearwire_dualmode_201* is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.
find: 0652-019 The status on /logs/6rl/data/backups/*gz* is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.
find: 0652-019 The status on /logs/p7p/data/backups/*gz* is not valid.
find: 0652-083 Cannot execute :: A file or directory in the path name does not exist.

---------- Post updated at 02:03 PM ---------- Previous update was at 01:58 PM ----------

Code revised....

Code:
#!/bin/ksh
#set -x
file_path1="/cddata/bi/logs/21l/data/cdr/"
file_path2="/cddata/bi/crm_ose/"
file_path3="/logs/21l/data/cem/"
file_path4="/logs/21l/data/archive/ "
file_path6="/logs/21l/data/dual4g/"
file_path7="/logs/6rl/data/backups/"
file_path8="/logs/p7p/data/backups/"
file_path9="/cddata/bi/"
file_path10="/cddata/bi2"
file_nm1="dat"
file_nm2="sprint_teoco_dly"
file_nm3="clearwire_dualmode_201"
file_nm4="gz"
daytype1=1
daytype2=10
daytype3=30
daytype4=90
find "$file_path1/*$file_nm1" -type f -mtime +$daytype2 -exec ls -l {} + >> ~/cleanup.log
find "$file_path2/*$file_nm1" -type f -mtime +$daytype1 -exec ls -l {} + >> ~/cleanup.log
find "$file_path3/*$file_nm1" -type f -mtime +$daytype2 -exec ls -l {} + >> ~/cleanup.log
find "$file_path4/*$file_nm2*" -type f -mtime +$daytype3 -exec ls -l {} + >> ~/cleanup.log
find "$file_path6/*$file_nm3*" -type f -mtime +$daytype3 -exec ls -l {} + >> ~/cleanup.log
find "$file_path7/*$file_nm4*" -type f -mtime +$daytype3 -exec ls -l {} + >> ~/cleanup.log
find "$file_path8/*$file_nm4*" -type f -mtime +$daytype3 -exec ls -l {} + >> ~/cleanup.log

# 4  
Old 02-17-2014
Oops I did not look well enough at your question. It should be something like

Code:
find "$file_path1" -name "*$file_nm1*" ....

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Consternation of multiple file names based on naming pattern

Hi, I have the following reports that get generated every 1 hour and this is my requirement: 1. 5 reports get generated every hour with the names "Report.Dddmmyy.Thhmiss.CTLR" "Report.Dddmmyy.Thhmiss.ACCD" "Report.Dddmmyy.Thhmiss.BCCD" "Report.Dddmmyy.Thhmiss.CCCD"... (1 Reply)
Discussion started by: Jesshelle David
1 Replies

2. Shell Programming and Scripting

How to rename multiple file names?

Hi all, I need to rename more file name in one command or script. The files have this structure: XxY - filename.doc where X and Y are numbers and the x is the letter itself. I need to rename these files with this structure: string.S0XEY.filename.doc the string is a suffix that... (8 Replies)
Discussion started by: idro
8 Replies

3. Shell Programming and Scripting

Checking Multiple File existance in a UNIX folder(Note: File names are all different)

HI Guys, I have some 8 files with different name and extensions. I need to check if they are present in a specific folder or not and also want that script to show me which all are not present. I can write if condition for each file but from a developer perspective , i feel that is not a good... (3 Replies)
Discussion started by: shankarpanda003
3 Replies

4. UNIX for Dummies Questions & Answers

How to remove first few characters from multiple file names without do loop?

Hi Fellows, I was wondering how I can remove first few characters from multiple file names without do loop in unix? e.g. water123.xyz water456.xyz to 123.xyz 456.xyz Thanks Paul Thanks. (3 Replies)
Discussion started by: Paul Moghadam
3 Replies

5. Shell Programming and Scripting

change multiple file names

Hi is it possible to change multiple files (~10k) names with out disturbing the data in it. ? input Hynda|cgr10(+):100027702-1000312480|.txt Hynda|cgr10(+):100027702-1000312483|.txt Hynda|cgr10(+):100027702-1000312484|.txt Hynda|cgr10(+):100027702-1000312482|.txt output... (4 Replies)
Discussion started by: quincyjones
4 Replies

6. Shell Programming and Scripting

KSH - Find paths of multiple files in CC (dir and sub-dir))

Dear Members, I have a list of xml files like abc.xml.table prq.xml.table ... .. . in a txt file. Now I have to search the file(s) in all directories and sub-directories and print the full path of file in a output txt file. Please help me with the script or command to do so. ... (11 Replies)
Discussion started by: Yoodit
11 Replies

7. UNIX for Dummies Questions & Answers

copying same file multiple times with different names

hi, I am copying a file from 1 folder to another in /bin/sh. if the file already exists there, it should get copied as filename1. again if copying next time it shouldget copied as filename2.. , filename3..so on.. The problem is i am able to get uptil filename1.. but how do i know what... (6 Replies)
Discussion started by: blackcat
6 Replies

8. Shell Programming and Scripting

Rename multiple file names in a directory

I hope some one can help me I have multiple files in a directory with out extension like as below mentioned. But i want to change all the file names along .DDMMYYYYHHMISS format. And all files should have same DDMMYYYYHHMISS. Scenario: direcory name = /vol/best/srcfiles files in a... (4 Replies)
Discussion started by: hari001
4 Replies

9. Shell Programming and Scripting

Change multiple file names

Hello, I have some files in a directory like: 01_07_2010_aa.txt 01_07_2010_bb.txt 01_07_2010_cc.txt 01_07_2010_dd.txt 01_07_2010_ee.txt 01_07_2010_ff.txt I want to change their names to : 3nm_aa.txt 3nm_bb.txt 3nm_cc.txt 3nm_dd.txt 3nm_ee.txt 3nm_ff.txt (8 Replies)
Discussion started by: ad23
8 Replies

10. UNIX for Dummies Questions & Answers

Editing multiple file names in one go

Hi there, I have a folder full of pdf's and I've run a compression on the to reduce the size, the output of the compress places a '-o' in the name of the file. Before 12345.pdf After 12345-o.pdf Now I've got around 50000 files that I need to change back to the previous name, is... (3 Replies)
Discussion started by: KeesH
3 Replies
Login or Register to Ask a Question