LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-03-2009, 04:14 PM   #1
andrew22
Member
 
Registered: Jan 2009
Location: Heaven
Distribution: Ubuntu 8.10 , openSUSE 11.1
Posts: 56

Rep: Reputation: 16
Question How can I pass the contents of a file into an integer?


I am trying to make a .sh programm , which will read the user input , pass it into an integer , write the integer into a file , then read the file , pass the contents of it in another integer , and the echo the last integer I am trying this
Code:
 #! /bin/bash
touch value
read val
echo "$val" > value
cat value | set $val2 
echo "$val2"
but , after all , is SET for that porpuse ? Can you give mesome corrections?
 
Old 02-03-2009, 04:29 PM   #2
Maligree
Member
 
Registered: Mar 2008
Distribution: Gentoo, CentOS, Fedora, Arch
Posts: 231
Blog Entries: 1

Rep: Reputation: 42
This should work..
Code:
read value1
echo $value1 > value_file
value2=`cat value_file`
echo $value2
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
how to append contents of one file to another existing file amit_pansuria Programming 1 11-17-2008 10:01 AM
Create File Shell Syntax and pass data to the file FirstBorn Linux - General 22 07-31-2008 09:48 PM
Bash remove part of a file based on contents of another file bhepdogg Programming 4 01-31-2007 03:13 PM
Pass the contents of firewall log to another file arubala1 Linux - Networking 2 03-16-2006 03:50 AM
Pass file adnanm Linux - Newbie 1 11-18-2005 11:30 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:27 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration