How Create new directory and move files to that directory.?
Hi All,
We have main directory called "head"
under this we have several sub directories and under these directories we have sub directories.
My requirement is I have to find the SQL files which are having the string "procedure" under "head" directory and sub directories as well.
And create new directory "procedure" under "head" and move all the files to the new directory.
head/procedure
In the "procedure" directory all the SQL files which contain the string "procedure" should be there.
Sounds like a one off action for me, not a regular repetitive task for a script. Where do you need help? mkdir to create directory. grep to look for keywords in files, evtl. with the -r option. mv to move the files found.
I note that your 1st post in this thread says you're looking for SQL files, but in post #3 in this thread your code is looking for sql files. The following assumes that your files follow the convention used in post #3. In the future, please state your requirements clearly in your first post. Changing requirements with each new post in a thread wastes everyone's time.
In the future, PLEASE tell us what operating system and shell you're using, so volunteers here don't waste their time making suggestions that won't work in your environment. We should not have to search through dozens of your earlier posts to guess at your environment so we can help you each time you start a new thread.
Obviously, you'll need to change /absolute/path/to/head in the above script to the actual absolute pathname of the head directory you want to use. (You didn't give a pathname for this directory in your first post and the 3rd post in this thread gives conflicting locations for it.)
The {} placeholder has a meaning for the find command alone. After piping find's output to the mv command, the file name found are supplied via stdin. You'll need something to convert stdin to parameters on the command line, xargs.
BUT - this may lead to problems as in file names with white space.
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)
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)
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)
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)
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)
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)
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)
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)