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.

[33] This is actually a script adapted from the Debian Linux distribution.<br />

[34] The print queue is the group of jobs "waiting in line" to be printed.<br />

[35] For an excellent overview of this topic, see Andy Vaught's article, Introduction to Named Pipes, in the<br />

September, 1997 issue of Linux Journal.<br />

[36] EBCDIC (pronounced "ebb−sid−ic") is an acronym for Extended Binary Coded Decimal Interchange<br />

Code. This is an IBM data format no longer in much use. A bizarre application of the conv=ebcdic<br />

option of dd is as a quick 'n easy, but not very secure text file encoder.<br />

cat $file | dd conv=swab,ebcdic > $file_encrypted<br />

# Encode (looks like gibberish).<br />

# Might as well switch bytes (swab), too, for a little extra obscurity.<br />

cat $file_encrypted | dd conv=swab,ascii > $file_plaintext<br />

# Decode.<br />

[37] A macro is a symbolic constant that expands into a command string or a set of operations on<br />

parameters.<br />

[38] This is the case on a Linux machine or a UNIX system with disk quotas.<br />

[39] The userdel command will fail if the particular user being deleted is still logged on.<br />

[40] For more detail on burning CDRs, see Alex Withers' article, Creating CDs, in the October, 1999 issue<br />

of Linux Journal.<br />

[41] The −c option to mke2fs also invokes a check for bad blocks.<br />

[42] Operators of single−user Linux systems generally prefer something simpler for backups, such as tar.<br />

[43] NAND is the logical "not−and" operator. Its effect is somewhat similar to subtraction.<br />

[44] For purposes of command substitution, a command may be an external system command, an internal<br />

scripting builtin, or even a script function.<br />

[45] A file descriptor is simply a number that the operating system assigns to an open file to keep track of it.<br />

Consider it a simplified version of a file pointer. It is analogous to a file handle in C.<br />

[46] Using file descriptor 5 might cause problems. When Bash creates a child process, as with<br />

exec, the child inherits fd 5 (see Chet Ramey's archived e−mail, SUBJECT: RE: File descriptor 5 is held<br />

open). Best leave this particular fd alone.<br />

[47] The simplest type of Regular Expression is a character string that retains its literal meaning, not<br />

containing any metacharacters.<br />

[48] Since sed, awk, and grep process single lines, there will usually not be a newline to match. In those<br />

cases where there is a newline in a multiple line expression, the dot will match the newline.<br />

#!/bin/bash<br />

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

sed −e 'N;s/.*/[&]/'

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

Saved successfully!

Ooh no, something went wrong!