This is the second part of this series of notes on the advanced use of the Unix shell. The first part can be accessed by following the link. In this second part, I will show some advanced examples I wrote for my research activity.
1. CHANGE FILE NAMES SCRIPT
I wrote this script to change the default names of the files generated during a molecular dynamics simulation by the program mdrun in the early version of the GROMACS package for MD simulation. GROMACS is a widely used software package for simulating the behavior of molecules and molecular systems. Although it is now possible to define the root name of the files upon running the simulation program, this script can still be helpful. The script is written in the C Shell (csh) .
#! /bin/csh -ef
#
# Change the names of the default output Files
# generated by the program GROMACS mdrun program
#
# (c) Danilo Roccatano
#######
#
#Define the radix of the files name
#
setenv RADIX 'EH_min'
if (-e md.log) then
if ( -e $RADIX'.log') then
echo Warning $RADIX'.log' exist
else
mv md.log $RADIX'.log'
endif
else
echo The md.log file does not exist!
endif
if (-e ener.ene) then
if ( -e 'e'$RADIX'.ene') then
echo Warning 'e'$RADIX'.ene' exist
else
mv ener.ene 'e'$RADIX'.ene'
endif
else
echo The energy file does not exist
endif
if (-e ctraj.xtc ) then
if ( -e 'r'$RADIX'.xtc') then
echo Warning 'r'$RADIX'.xtc' exist
else
mv ctraj.xtc 'r'$RADIX'.xtc'
endif
else
echo The compressed trajectory file does not exist
endif
if (-e confout.gro) then
if ( -e 'x'$RADIX'.gro') then
echo Warning 'x'$RADIX'.gro' exist
else
mv confout.gro 'x'$RADIX'.gro'
endif
else
echo The final configuration file does not exit.
echo Probably your simulation crashed before the end
endif
exit
