I am using bash. I have been having success working with loops and variables, and what I want to do is get a list of directories in my current directory, and with a DO-WHILE loop get the first name in the list and make it the variable DIRECTORYTOWORKWITH, then work with the directory, the go to the next directory in the list, and start over.
I know I can do it with 'find' and pipes, but I don't fully understand all the options { like -r and print() }, nor to I know how to parse the list one item at a time.
Start by reading the man pages for your shell (bash) and for the find utility:
Unfortunately both of those are long man pages with lots of words with very detailed meaning that may be foreign to you as a beginner. On the bash man page pay special attention to the sections titled DEFINITIONS, SHELL GRAMMAR (where you'll learn about pipelines, &&, ||, and a bunch of other shell magic), QUOTING, and EXPANSIONS (especially the subsection titled Pathname Expansion).
Fortunately, both of those pages usually have examples that you can play with to get an idea of how things work. Play with those examples. Try to expand what you learn from those examples to do other things you want to do. And consider the two examples below...
First, if you want to process directories in the current directory, try:
And second, if you want to process all directories in and under the current directory starting with the directories deepest in the current file hierarchy, try:
And then, if you get lost or can't understand what the man pages are saying, come back here and ask questions.
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... (14 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)
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)
Hi All,
So I have another question. I'm trying to search for files with a certain extension and then move all of them up one level in the folder hierarchy.
So something like this:
original: /path/to/file/test.txt
after: /path/to/test.txt
I had some great help recently with another... (4 Replies)
Im trying to move my files to a variable folder i've just created.
Step 1 is working fine.
mkdir /sdcard/DCIM/Photos/`date +%Y%m%d`
Step 2 is not working
mv /sdcard/DCIM/100ANDRO/*.jpg /sdcard/DCIM/Photos/`date +%Y%m%d`
What am i doing wrong? (2 Replies)
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)
Hi,
I am trying to write a script that will move all the files from source directory structure(multiple levels might exist) to destination directory structure. If a sub folder is source doesnot exist in destination then I have to skip and goto next level. I also need to delete the files in... (4 Replies)