Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trouble displaying information with printf

Status
Not open for further replies.

jalge2

Technical User
Feb 5, 2003
105
US
Hi all. The trouble that I have run into is the printf command. We have a bunch of batteries here for our scan guns. They all have a certain number and barcode on them and whenever we change a battery, we scan the battery in and out. The script that I have written is, to enter on of these numbers and it will display every record for that particular battery. It dispays the information correctly, but it's not organized enough to suit my boss (big suprise). Anyway, I'm a newer user to AIX and the man files aren't helping very much. Here is my script.

# /bin/ksh!

echo "\tPlease enter the battery number you wish to search for..."
read ans

if [[ $ans != 0 ]]

then
cat /dso/eis/log/batlog.log.* |grep $ans > /dso/eis/log/battsearch.log
more /dso/eis/log/battsearch.log
fi

echo "\tWould you like to print this? (y/n)"
read ans1

if [ $ans1 = "y" -o $ans1 = "Y" ]

then
lp -dps@pr7 /dso/eis/log/battsearch.log

else
exit
fi

And here is the output

,06/29/03,22:04,9901538,Cory Cole,DCO,OUT,4270801,PROD

So my question is, how do I use the printf command to get this information organized? Thanks for any help I get.

Jason

 
Hi,

First of all although the printf works in a shell script, its usually used in a C program. Most of the time, the echo command is the one used to display data. Looking at your script, I believe you just need to separate the data in the your logs and put it into separate variables. You could try using the 'cut' command to get the info you need.

e.g. to get the date set variable tdate=$(cat /dso/eis/log/battsearch.log | cut -c2-9)

Then use the echo command to display your output:

echo Date is $tdate
echo Time is $ttime

Good Luck
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top