How Create new directory and move files to that directory.?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How Create new directory and move files to that directory.?
# 8  
Old 05-02-2016
Hi Don,

I have tried the below script and no files moved to the directory "procedure"
even we have SQL files with string procedure.

path for head is /home/head

Code:
#!/bin/ksh
head=/home/head

mkdir -p "$head/procedure"
find "$head" \( -type d -name procedure -prune \) -o \
    \(	-type f -name '*.sql' -exec grep -q -F 'procedure' {} \; \
    	-exec mv {} "$head/procedure" \; \)

Please helpme.

Thanks

Last edited by ROCK_PLSQL; 05-02-2016 at 05:25 AM.. Reason: Add CODE tags again.
# 9  
Old 05-02-2016
Did you get any diagnostic messages when you ran the script?

What operating system are you using?

Please show us the absolute pathname of an SQL file with a name ending in .sql that contains the string procedure. Show us the results from the commands:
Code:
ls -l path
grep procedure path

where path is the absolute pathname of one of the files that is not being moved by the script I suggested.
# 10  
Old 05-02-2016
Hi don,

Please find the details as below

Version M-11/16/88i

Korn shell

We have sql files with the string procedure in the follwoing paths.

/head/sql
head/db


Thanks

---------- Post updated at 06:01 PM ---------- Previous update was at 04:07 PM ----------

Hi Don,

Can u please help me.

Thanks
# 11  
Old 05-02-2016
Quote:
Originally Posted by ROCK_PLSQL
Hi don,

Please find the details as below

Version M-11/16/88i

Korn shell

We have sql files with the string procedure in the follwoing paths.

/head/sql
head/db


Thanks

---------- Post updated at 06:01 PM ---------- Previous update was at 04:07 PM ----------

Hi Don,

Can u please help me.

Thanks
I will be happy to help you if you provide the data I requested in post #9 in this thread. Without an example showing what is misbehaving, I can't help. The code I suggested works perfectly with the sample data I created on my system to test what I understood to be your requirements. (But, bumping up posts and thinking that I should be on call 24 hours/day to solve your problems is unacceptable.)

And, PLEASE tell us what operating system you're using! Version M-11/16/88i is not an operating system (although it might be a version number or a release number of an operating system). If you don't know what operating system you're using, please show us the output from the command:
Code:
uname -a

# 12  
Old 05-03-2016
Hi Don,

This is the version
SunOS 5.10 Generic_147440-13 sun4u sparc SUNW

Please help me.

Thanks
# 13  
Old 05-03-2016
In post #9 in this thread, I said:
Quote:
Please show us the absolute pathname of an SQL file with a name ending in .sql that contains the string procedure. Show us the results from the commands:
Code:
ls -l path
grep procedure path

where path is the absolute pathname of one of the files that is not being moved by the script I suggested.
Until you provide this information, there is nothing we can do to help!
# 14  
Old 05-04-2016
Hi Don,

Code:
/head/sql>ls -l /head/sql

I got lot of files

Code:
/head/sql>grep procedure /head/sql

it's got giving any files.

Code:
/head/sql>grep procedure *.sql

It's giving files

Please help me.
Moderator's Comments:
Mod Comment PLEASE use CODE tags as required by forum rules for all sample input, all sample output, and all code segments. Continued refusal to properly format your posts may result in you being banned from this site.


Thanks

Last edited by Don Cragun; 05-04-2016 at 02:05 PM.. Reason: Add CODE tags again.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

2. UNIX for Dummies Questions & Answers

How to move gz files from one source directory to destination directory?

Hi All, Daily i am doing the house keeping in one of my server and manually moving the files which were older than 90 days and moving to destination folder. using the find command . Could you please assist me how to put the automation using the shell script . ... (11 Replies)
Discussion started by: venkat918
11 Replies

3. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

4. Shell Programming and Scripting

Move files in a list to another directory

I have a number of files in a directory that can be grouped with something like "ls | grep SH2". I would like to move each file in this list to another directory. Thanks (4 Replies)
Discussion started by: kg6iia
4 Replies

5. UNIX for Dummies Questions & Answers

Zip all files in a directory and move to another directory

Hi, need to zip all files in a directory and move to another directory after the zip.. i am using this one but didnt help me... zip -r my_proj_`date +%Y%m%d%H%MS`.zip /path/my_proj mv in_proj_`date +%Y%m%d%H%M%S`.zip /path/source/ i am trying to zip all the files in my_proj... (0 Replies)
Discussion started by: dssyadav
0 Replies

6. UNIX for Dummies Questions & Answers

How to move files between 2 dates from one directory to another

Hi All, I am coding for a requirement where I need to move files (filename.yymmdd) from one directory(A) to another(B) based on 2 date fields in a paramtere file. (Paramfile.txt) For e.g: In Paramfile.txt, BUS_DT =20120612 SUB_DT =20120602 In this case, i need to move all the files... (14 Replies)
Discussion started by: dsfreddie
14 Replies

7. Shell Programming and Scripting

Move the latest or older File from one directory to another Directory

I Need help for one requirement, I want to move the latest/Older file in the folder to another file. File have the datetimestamp in postfix. Example: Source Directory : \a destination Directory : \a\b File1 : xy_MMDDYYYYHHMM.txt (xy_032120101456.txt) File2: xy_MMDDYYYYHHMM.txt... (1 Reply)
Discussion started by: pp_ayyanar
1 Replies

8. Shell Programming and Scripting

Move a file from windows directory to unix directory

Move a file from windows directory to unix directory, is this possible? if it is, can someone help me on this? Thanks! God bless! (1 Reply)
Discussion started by: kingpeejay
1 Replies

9. UNIX for Dummies Questions & Answers

Move all files in a directory tree to a signal directory?

Is this possible? Let me know If I need specify further on what I am trying to do- I just want to spare you the boring details of my personal file management. Thanks in advance- Brian- (2 Replies)
Discussion started by: briandanielz
2 Replies
Login or Register to Ask a Question