wiki:Documentation/UserGuide/ShellScript

Version 3 (modified by pmaugis, 4 years ago) (diff)

--

How to write a shell script

Author: S.Luyssaert Last revised: 2020/02/28, P. Maugis

A super simple script for recurring tasks

We want to make a script that deletes all the history and restart files from ORCHIDEE so that we can run the next simulation within the same file structure with the same starting time. We will call the command clean.sh.

Open an editor for the command file, i.e. 'clean.sh'

emacs ../bin/clean.sh

Write the linux commands in the editor. Here, we selct 'bash' as the shell-interpreter.

#!/bin/bash
rm -f ../Output/*_history.nc ../Restart/*_out.nc ../bin/output.txt

Save the file and change the permissions so the file can be executed

chmod +x clean.sh

you can now type clean.sh to execute the linux commands from the file 'clean.sh'