I came up with a basic one to help automate the process of removing a number of folders as they become unneeded.
#!/bin/bash
rm -rf ~/myfolder1/$1/anotherfolder
rm -rf ~/myfolder2/$1/yetanotherfolder
rm -rf ~/myfolder3/$1/thisisafolder
This is evoked like so:
./myscript.sh <{id-number}>
The problem is that if you forget to type in the id-number
(as I did just then), then it could potentially delete a lot of things that you really don't want deleted.
Is there a way you can add any form of validation to the command line parameters? In my case, it'd be good to check that a) there is one parameter, b) it's numerical, and c) that folder exists; before continuing with the script.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…