27.08.2015 Views

Advanced Bash−Scripting Guide

Advanced Bash-Scripting Guide - Nicku.org

Advanced Bash-Scripting Guide - Nicku.org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

#+ because it contains both "begin" and "end".<br />

# Exercise:<br />

# Modify this script to check for a newsgroup header.<br />

exit 0<br />

<strong>Advanced</strong> <strong>Bash−Scripting</strong> <strong>Guide</strong><br />

The fold −s command may be useful (possibly in a pipe) to process long uudecoded<br />

text messages downloaded from Usenet newsgroups.<br />

mimencode, mmencode<br />

The mimencode and mmencode commands process multimedia−encoded e−mail attachments.<br />

Although mail user agents (such as pine or kmail) normally handle this automatically, these<br />

particular utilities permit manipulating such attachments manually from the command line or in a<br />

batch by means of a shell script.<br />

crypt<br />

At one time, this was the standard UNIX file encryption utility. [31] Politically motivated government<br />

regulations prohibiting the export of encryption software resulted in the disappearance of crypt from<br />

much of the UNIX world, and it is still missing from most Linux distributions. Fortunately,<br />

programmers have come up with a number of decent alternatives to it, among them the author's very<br />

own cruft (see Example A−5).<br />

Miscellaneous<br />

mktemp<br />

Create a temporary file with a "unique" filename.<br />

make<br />

PREFIX=filename<br />

tempfile=`mktemp $PREFIX.XXXXXX`<br />

# ^^^^^^ Need at least 6 placeholders<br />

#+ in the filename template.<br />

echo "tempfile name = $tempfile"<br />

# tempfile name = filename.QA2ZpY<br />

# or something similar...<br />

Utility for building and compiling binary packages. This can also be used for any set of operations<br />

that is triggered by incremental changes in source files.<br />

The make command checks a Makefile, a list of file dependencies and operations to be carried out.<br />

install<br />

Special purpose file copying command, similar to cp, but capable of setting permissions and attributes<br />

of the copied files. This command seems tailormade for installing software packages, and as such it<br />

shows up frequently in Makefiles (in the make install : section). It could likewise find use<br />

in installation scripts.<br />

dos2unix<br />

This utility, written by Benjamin Lin and collaborators, converts DOS−formatted text files (lines<br />

terminated by CR−LF) to UNIX format (lines terminated by LF only), and vice−versa.<br />

ptx<br />

The ptx [targetfile] command outputs a permuted index (cross−reference list) of the targetfile. This<br />

may be further filtered and formatted in a pipe, if necessary.<br />

more, less<br />

Pagers that display a text file or stream to stdout, one screenful at a time. These may be used to<br />

Chapter 12. External Filters, Programs and Commands 190

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!