Linux FAQ's & Manuals
- Linux Scripts
- Debian Install
- Bash For Beginners
- Bugzilla
- Consultants Guide
- GCC Manual
- Linux Command Line Tools
- Gnu Pascal Coding Standards
- Linux Installation Disk
- Labolatorium Linux(PL)
- Budowa systemu Linux(PL)
- Linux Dictionary
- Network Administrators
- Rescue Disk for Linux
- Red Hat Installation
- Red Hat Customization
- Red Hat Getting Started
- Red Hat Security
- Secure & Optimize
- Slackware Manual
- Suse Support
- Suse FAQ
iTWire: "Gadget geeks worldwide are collaborating to make the ubiquitous TomTom GO portable satellite navigation system more useful..."
Linux: CFS and Nice
KernelTrap: "The recently merged Completely Fair Scheduler changes how the Linux kernel handles scheduling priorities set with the nice command..."
Virtual Hosting With PureFTPd And MySQL On Mandriva 2007 Spring
HowtoForge: "This document describes how to install a PureFTPd server that uses virtual users from a MySQL database instead of real system users..."
How to Handle Thousands of Users with Your Blog
ThemBid: "There have been multiple occasions where I am trying to read an article and the website is down..."
Setting Up SSH2 on Red Hat Enterprise Linux
SearchOpenSource: "This tip describes how to set up SSH2 (Secure Shell) on Red Hat Enterprise Linux (RHEL) and to use encryption keys instead of passwords..."
9.4. i/0 redirection and loops
9.4.1. input redirection
instead of controlling a loop by testing the result of a command or by user input, you can specify a file from which to read input that controls the loop. in such cases, read is often the controlling command. as long as input lines are fed into the loop, execution of the loop commands continues. as soon as all the input lines are read the loop exits.
since the loop construct is considered to be one command structure (such as while test-command; do consequent-commands; done), the redirection should occur after the done statement, so that it complies with the form
command < file
this kind of redirection also works with other kinds of loops.
9.4.2. output redirection
in the example below, output of the find command is used as input for the read command controlling a while loop:
[carol@octarine ~/testdir] cat archiveoldstuff.sh #!/bin/bash # this script creates a subdirectory in the current directory, to which old # files are moved. # might be something for cron (if slightly adapted) to execute weekly or # monthly. archivenr=`date +%y%m%d` destdir="$pwd/archive-$archivenr" mkdir $destdir find $pwd -type f -a -mtime +5 | while read file do gzip "$file"; mv "$file".gz "$destdir" echo "$file archived" done |
files are compressed before they are moved into the archive directory.