Next: Customizing your shell
Up: Working with the shell
Previous: Setting environment variables
- Shell scripts allow you to automate things. I actually don't know
shell scripting very well; if I need to do anything complicated, I
tend to use Perl, which can call the operating system easily.
- Here's one way to loop through files in a directory and do something
to each file (this uses the C shell). Place script code like that
below in a file, e.g. loop.csh, make sure loop.csh is executable (>chmod
guo+x loop.csh) and then run it: >loop.csh
foreach name (`ls *.dat`)
echo "`basename $name .dat`"
perl tmp.pl < $name
end
- foreach name ( `ls knots*` )
set name2="$name.e.g.10"
mv $name $name2
end
Chris Paciorek
2006-04-02