Unix automation

From "A B C"
Jump to navigation Jump to search

Automating tasks in Unix.


The contents of this page has recently been imported from an older version of this Wiki. This page may contain outdated information, information that is irrelevant for this Wiki, information that needs to be differently structured, outdated syntax, and/or broken links. Use with caution!


The unix command line provides an interpreted programming environment. Some things are easier to achieve with a shell script than with a perl program. However, you can get everything done in perl that you can do in a shellscript and that saves you the need to learn yet another syntax.


 

Introductory reading



 


Shellscripts

[...]


cron

[...]


Examples

Change extensions for many files

To change all .htm files in a folder to .html files:

  • using basename to extract the actual filename from a string...
<bash>for f in *.htm; do mv $f `basename $f .htm`.html; done;</bash>
  • or, using echo to pipe the filename into sed and applying a regular expression/substitution...
<bash>for f in *.htm ; do mv $f `echo $f | sed 's/\(.*\.\)htm/\1html/'` ; done</bash>


   

Further reading and resources