Script to copy specific directory based on variable to folder with that variable name
So this is what I want the script to do.
I plug in a usb harddrive, I mount the drive manually. I want the variable to be a username. Then the script copies these files after making the directory for the user mkdir /home/usrbak/username cp -rfn /media/Disk/Documents\ and\ Settings/username/Favorites /home/usrbak/username cp -rfn /media/Disk/Documents\ and\ Settings/username/Desktop /home/usrbak/username cp -rfn /media/Disk/Documents\ and\ Settings/username/My\ Documents/ /home/usrbak/username cp -rfn /media/Disk/Documents\ and\ Settings/username/Local\ Settings\Application/ Data\Microsoft\Outlook\*.pst /home/usrbak/username and that's it. So the script really only needs me to answer two questions, #1 what is the name of the mount, and #2 what is the name of the user. So those are variables, anyone have a simple tutorial for a script like this? I even might automate the mounting of the disk as well. thanks for the reply below =_) |
Code:
#!/bin/sh script username /media/Disk |
so I run the script ./back username /media/disk/
it errors on the 2nd line, cannot create directory, as it doesn't seem to input variable 1. This is after I removed the -p, which gives a command not found error instead. |
The &1 on line 2 should be a $1
Sasha |
Quote:
|
I just finished a class up on linux administration and learned about redirection with &1 < \, etc.
So I guess I can do this kind of script with many things. Thanks for the help. |
Quote:
|
You can easily learn a lot more about bash with Bash Guide for Beginners and with Advanced Bash-Scripting Guide. You'll get a lot of difference even with just a quick glance.
Also remember that 'man bash' is your friend. |
All times are GMT -5. The time now is 04:10 PM. |