Custom Search
www.rocket99.com : Technical Guides Sybase Oracle UNIX Javascript


Technical Guides
Sybase
Oracle
UNIX
Javascript




Of Interest

Business Intelligence and Analytics



Oracle Training





UNIX » Shell » Coding »

Scan a file in a shell script

     





-- loop and scan a file : reads 1 token at a time.

for fname in `cat test1.dat` ; do

echo "Read line: " $fname

done




-- Read a file in Bash, 1 line at a time.

cat $logfile | egrep '[A-Z]|[a-z]|[0-9]' | while read line
do
/usr/local/bin/logger.sh message $logfile
done



-- Sample code, asks user for input within the loop!

for last_name in `cat $list1` ; do

echo "Create report card (y/n):" $last_name
read sel1

if test $sel1 = "y"; then
rpt=${last_name}.txt

echo "Report Card Header" > $rpt
fi

done











UNIX : Related Topics

UNIX : Shell : Wait for sentinel file to clear
UNIX : Shell : Formatting a date

Sybase Web Site
Sybase iAnywhere Mobile Web Site
Oracle Enterprise Web Site



Get the latest Rocket99 news and tech tips via






Site Index About this Guide to Sybase, Oracle, and UNIX Contact Us Advertise on this site




Copyright © 2016 Stoltenbar Inc All Rights Reserved.