bash script to create folders including making recursive folders....
hi all,
im trying to write a script in the bash shell. but im stuck. (noob) the command im trying to do is. CLIENT_NAME= name put in on command line mkdir -p /srv/store/nearling-storage/clients/{$CLIENT_NAME/audio,graphics,file,test/{test-staging,TEST-EXPORT},test1/{gra,aud}} currently the files are being made incorrectly, which is another issue. ive got the above wrong i think. (well i know duh.... ) ideally what i need is a script to run from the command line... so ./scriptname -newclientname and it then create the above folders. anyhelp would be great. thanks |
Quote:
If the client was XX, would you want to create these folders Code:
/srv/store/nearling-storage/clients/XX/audio |
Try getopt
I think 'getopt' command is what you're looking for. If '-newclientname' is of the type '-newclientname=XXX' then you need to parse XXX out before using it.
|
Quote:
thanks ( sorry for the confusion ) |
Quote:
shell$ ./script john for client john? And if $1 happens to be empty when the script error-checks for the clientname, exit with an error message (and of course, make sure john doesn't already exist too!) |
ive had a though, i might aswell just do, mkdir 7 times. was trying to be to clever, but the definition of clever is to realise that there may be a better way of doing something, but if it takes longer than the simpler version to get working and achieves the same thing...
silly me. ive got exactly what i need now anyway. momment of madness. sorry for the stupid post. thanks for the help. |
Quote:
Code:
#!/bin/bash |
Quote:
Thanks for making me learn about the {<string>[,<string> ...]} technique -- it's useful but I have never used it :doh: |
Quote:
I was in the process of making a simple sed to replace any spaces with underscores, but then realized this would mean other (unnecessary and excessive) mods to catkins script, to grab >1 words given as a client_name and make them one name. If the OP wishes for this, it wouldn't be too hard, but as it stands, this looks adequate :) Sasha |
All times are GMT -5. The time now is 09:58 PM. |