nixCraft Linux Forum

nixCraft

Linux Tech Support Forum

Read one integer from a file, cannot find info

This is a discussion on Read one integer from a file, cannot find info within the Shell scripting forums, part of the Development/Scripting category; I have read three linux scripting tutorials and still cannot find the answer to this... To many of you this ...


Go Back   nixCraft Linux Forum > Development/Scripting > Shell scripting

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 05-07-2008, 05:40 AM
Junior Member
User
 
Join Date: May 2008
My distro: knoppix
Posts: 1
Rep Power: 0
beginer is on a distinguished road
Default Read one integer from a file, cannot find info

I have read three linux scripting tutorials and still cannot find the answer to this... To many of you this may sound too simple, but as a beginner I am having a real hard time finding out how to read a single integer stored in a file, to process its value thereafter. his is what I have:

# user at console types input data file name:

read fname1

# open fname1 and load integer to int1

open $fname1
read $fname1, int1
echo expr $int1 / 2

That's all I need to do, please help me with the syntaxt, I am following the tutorials but would like to know how to open, read a data element so I can do something with it before I go forward.

Thank you
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 05-13-2008, 05:44 PM
agn agn is offline
Member
User
 
Join Date: Feb 2008
My distro: OpenBSD/FreeBSD/Debian/Fedora/RHEL
Posts: 69
Rep Power: 1
agn is on a distinguished road
Default

Something like this

Code:
read FILE
int1=`cat $FILE`
echo `expr $int1 / 2`
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads

Thread Thread Starter Forum Replies Last Post
To find and replace in text file nashtech Shell scripting 3 07-31-2008 06:46 PM
Read arguments from a file and pass them to binary file AHJ Shell scripting 1 10-31-2007 06:04 PM
can not find the username in /etc/passwd file subrata1in Getting started tutorials 5 03-27-2007 11:45 AM
can not find user name in /etc/passwd file subrata1in Linux software 2 03-26-2007 10:44 AM
find out info. reg. files for each user in the system ganes Solaris/OpenSolaris 6 09-20-2005 06:49 PM


All times are GMT +5.5. The time now is 06:00 AM.


Powered by vBulletin® Version 3.7.2 - Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36