Generic script to recursively cd into directories and git pull
Hi all,
I'm trying to write a script to recursively cd into my Git projects and pull them, and will later expand it to build my projects as well.
I'm having a bit of trouble with my current script, as I want to supply a command line argument to tell it which branch to check out. I can hard code it to check out a specific branch but it's failing to take in my arguments.
My current script is:
A snippet of the output when I run it from the top level of a directory containing many git projects is:
So it looks like the -exec part of the script isn't pulling in my arguments and is just defaulting to the current branch. Any ideas on how to resolve this will be much appreciated. I don't mind if I have to rework how the script works entirely.
The recursive part of the script seems to work fine. If I run the script from ~/windows/Workspace/git-projects, it correctly descends into my-project, my-project-2, my-other-project, etc.
Thanks in advance for any help.
Edit: Fixed formatting. Sorry mods!
Last edited by Cows; 08-25-2017 at 07:07 AM..
Reason: Changed NOPARSE to CODE tags.
Without digging deeper: text within single quotes ' won't be expanded by the shell. In your above construct, it's a bit difficult to tell what is to be expanded by the parent shell, and what were to be passed unaltered to the subshell. But almost for sure, the second will not know about $BRANCH if that is not exported.
So it might be worthwhile to
- export variables for subshells
- replace single by double quotes, but make sure double quotes intended for the subshell are escaped.
Without digging deeper: text within single quotes ' won't be expanded by the shell. In your above construct, it's a bit difficult to tell what is to be expanded by the parent shell, and what were to be passed unaltered to the subshell. But almost for sure, the second will not know about $BRANCH if that is not exported.
So it might be worthwhile to
- export variables for subshells
- replace single by double quotes, but make sure double quotes intended for the subshell are escaped.
Thanks for the pointer. I thought it would be something to do with that. I've got it working now after exporting $2 before calling the subshell.
i have directory dgf
in the dgf( some other Sub-dir are there)
00 01 02 03 04
in all the Sub directory there is a SG.csv ..
i want the scripts should run one by one Sub-dir and print the result for that particular Sub-dir ..then go to next Sub-Dir and print the result.......
please... (6 Replies)
I have directory path in which there are several sub directories. In all these sub dir there will be one env.cnf file. I want to copy this env.cnf file from
each sub dir's and place them in destination path by creating same filename as sub dir_env.cnf.
After copying env.cnf files from source... (4 Replies)
Hi,
Seems like I need help again with a problem:
I want to delete all files from my lets say "Music" Directory inkluding all of the subfolders
except for .mp3 and .MP3 files.
I tried it with globalignoring mp3 files, finding and deleting all other files, which
resulted in all files... (3 Replies)
I have this directory tree under /apps/myapp/data:
imageshack.us/photo/my-images/703/foldersc.png
How to recursively rename ONLY directories with 5 digits (00000, 00100, 00200,..., 00007, 00107,...)?
I want to add to their name two more zeros:
Before: 00107
After: 0000107
Thanks in... (2 Replies)
Hi,
I want to delete all empty directories in a long directore tree structure. I want to use that from a script that will run on HP-UX 11. My definition of empty directory is that there is no regular file under it and directly beneath it. To elaborate, I have below directories.
/app/dev/java... (14 Replies)
Hi,
Please help me, how to get all the direcotries, its sub directories and its sub directories recursively, need to exclude all the files in the process.
I wanted to disply using a unix command all the directories recursively excluding files.
I tried 'ls -FR' but that display files as... (3 Replies)
Hi All,
We have a requirement to recursively delete the directories and its subdirectories older than 60 days based on timestamp (folder creation timestamp)under certain directory. However it has some specific requirements.
The directories will continue to be there upto any depth.
the... (0 Replies)
Cannot find how to list the directory structure of a volume recursively. Do not want the files reported. Say I have 100 directories and 10,000 files, I do not want 10,000 lines of output. (If this is relevant, I am using the terminal on my OSX Mac). I hope this is easy - there should be an easy... (5 Replies)
Say I have a directory call test, and several directories nested in it, and several directories nested in them. And I want to remove all directories within "test" and its subdirectories that have the name "cvs", how can I do this?
I tried rm -r cvs, but that only removed the top level direcotry... (4 Replies)