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
|
|
|
Get the latest Rocket99 news and tech tips via
|