Help making shell script for basic command

Joined
May 14, 2012
Messages
7
Reaction score
0
Points
1
I need to make a shell script for a command to create aliases for 500 folders in 500 parent directories. I've found one page that was useful (http://www.alvinpoh.com/how-to-make-and-run-batch-files-in-terminal-in-mac-osx/), however I need to put the aliases on several computers, and once the aliases made with that script are off my computer, the aliases are "dead," due to rights permissions, I assume.

The command works when I copy and paste the commands one by one into Terminal, but I'd rather not do that.

Example of folder structure
server/
.......people/
.............person1/
.............person2/ etc.

Example of command being used
ln -s "/Volumes/server/people/person1" /shortcuts/

Thanks for any help.
 

Raz0rEdge

Well-known member
Staff member
Moderator
Joined
Jul 17, 2009
Messages
15,745
Reaction score
2,071
Points
113
Location
MA
Your Mac's Specs
2022 Mac Studio M1 Max, 2023 M2 MBA
On Linux (that's what I have access to right now) something like this would work
Code:
for dir in `find /Volumes -mindepth 3`; do
    ln -s "$dir " /shortcuts/
done

The mindepth here ensures that you get the "server/people/personX" level. Without that, you end up getting "server" and "server/people" as well which you probably don't want.

If mindepth is supported by OS X's "find", then this script should work..
 
OP
E
Joined
May 14, 2012
Messages
7
Reaction score
0
Points
1
Thanks, I see what you're getting at there, but that line of code didn't work. Here's a site with how OS X uses mindepth. Any suggestions how to change it to work? Thanks.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top