In my professionnal experience I have to manage many PC running with Windows XP. Those box are used for broadcasting some video flow and download lot of media files which aren’t managed by our software. Naturally, I had to find a solution for dynamically purge the lot of useless media files daily generated. As everyone working in system administration (I suppose...), I didn’t have lot of time for doing this job and our software developper couldn’t add the possibility to destroy old files (still due to lot of projects and short timeline...), so I decide to use the Windows schedule (AT) and doing a batch file.
As we had different software version - and for a maximum flexibility in case of any "kidding" evolution of this software - I take care to use arguments to my script. Here by I’ll describe all the process of this script that can be resume in five parts :
- Get and check our arguments
- Checking some dates (OS date format, maximum vailidity date)
- Parsing the directory to purge and get last access date of files
- Testing date and delete useless files
- Scheduling the batch file
Do you know the environment variable $CDPATH? This variable let you define some path where to look for a directories when moving with the command CD. You can define multiple path in this variable. This can be usefull if you have some directories that you access more frequently than the others. As this variable define the order how you move from a directory to another, I suggest you to keep the "." directory in first position of your variable declaration. Of course, you can set this variable in your .bashrc
nicolas@grimm:~$ export CDPATH=.:/:~/ nicolas@grimm:~$ cd usr<br /> /usr<br /> nicolas@grimm:/usr$ cd Desktop<br /> /home/nicolas/Desktop
You probably have set some personnal alias or function on your box. Most common is probably dir, ls, ll... If you forgot how you define your alias or function, the easiest way for get back the definition isn't to read your numerous .bashrc but using some bash built-in command : type or command.
type: usage: type [-afptP] name [name ...] command: usage: command [-pVv] command [arg ...]
Command is generally used for running command with arguments ignoring any shell function named command. Instead of Type that describe a command, for each name, indicate how it would be interpreted if used as a command name. But both can be used, here is some examples :
[root@host ~]# alias -p alias cp='cp -i' alias mv='mv -i' alias rm='rm -i' [root@host ~]# command -v rm alias rm='rm -i' [root@host ~]# command -V rm rm is aliased to `rm -i' [root@host ~]# type rm rm is aliased to `rm -i'