Sponsored Content
Top Forums Shell Programming and Scripting Read a number from file and place it back Post 302323798 by dcoolsam on Tuesday 9th of June 2009 03:35:34 AM
Old 06-09-2009
MySQL

Vinay,
Try this code:

read i < a
i=`expr $i + 1`
echo $i > a
cat a

It is working perfectly fine in bash.

Here "a" is a file name where the number is stored & "i" is a temp variable.

Let me know if you need any more info.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

To read and separate number and words in file and store to two new file using shell

hi, I am a begginer in unix and i want to know how to open a file and read it and separate the numbers & words and storing it in separate files, Using shell scripting. Please help me out for this. Regards S.Kamakshi (2 Replies)
Discussion started by: kamakshi s
2 Replies

2. Shell Programming and Scripting

Place number with awk

Hello, if I've a list of number 23 34 56 78 how I can place a sequence of ordinated number in a boundary column so 1 23 2 34 3 56 4 78 Thanks in advance! (3 Replies)
Discussion started by: cv313x
3 Replies

3. Shell Programming and Scripting

How to read n number of lines from a file

Hiii I am very new to shell scripting.This is my data file a.txt: 56 45.78 1000 11.23 76.89 45 34.56 23 3400 100 .......... Now i am must use shell scripting to read n number of lines from the file & from ts n number of lines i need to find greatest number among them & so on for... (44 Replies)
Discussion started by: varsha
44 Replies

4. UNIX for Dummies Questions & Answers

How to read contents of a file from a given line number upto line number again specified by user

Hello Everyone. I am trying to display contains of a file from a specific line to a specific line(let say, from line number 3 to line number 5). For this I got the shell script as shown below: if ; then if ; then tail +$1 $3 | head -n $2 else ... (5 Replies)
Discussion started by: grc
5 Replies

5. Shell Programming and Scripting

Read from file specific place in file using inode

Hello, I am using tcsh on AIX. I would like to write a script that does the following: 1. given an inode, how do I find exactly the name of the file? I know I could do this using ls -i | grep <inode> but it returns: <inode> <filename>. I need some string manipulation or something to... (1 Reply)
Discussion started by: lastZenMaster
1 Replies

6. Shell Programming and Scripting

Bash Script Help...search then read from file: change text and pipe back...

Hello, I am trying to make a bash script that can pull data from a file and then change one part of said data. I want to search by username and pull the full line. That way there is a way to replace just one part of that line then return it back to the file. My Data is stored like: ... (1 Reply)
Discussion started by: serverfull
1 Replies

7. Shell Programming and Scripting

Take input from read and place it a string in another file

Hi, This is most likely a dumb question but I could not find answer to it elsewhere. I'm building a simple menu with case /esac and want to read user's input: Please enter XYZ ; read XYZ How do I take the value of XYZ and insert it as a variable $XYZ in file file.txt ? I may need to... (9 Replies)
Discussion started by: svetoslav_sj
9 Replies

8. Shell Programming and Scripting

How to read a number from a file?

hello guys, I'm struggled to get a number from a very long text file. NAtoms= 33 NActive= 30 NUniq= 23 SFac= 1.00D+00 NAtFMM= 60 NAOKFM=F Big=F Integral buffers will be 131072 words long. Raffenetti 2 integral format. The number 33 is what I wanted, always follows NAtoms=... (5 Replies)
Discussion started by: liuzhencc
5 Replies

9. Shell Programming and Scripting

Zero padding a Number before and after a decimal place

Hi I was hoping someone could help me with a sed script I am trying to write? I am on a Mac running ElCapitan I have some text that I have converted from a pdf that I want to format into an xml file. In the file I have managed to delete all the text I do not need. The text I have left is... (8 Replies)
Discussion started by: Paul Walker
8 Replies

10. UNIX for Beginners Questions & Answers

File manipulation place 0 before the number using sed

I'm new with sed, and i am really confused with slashes, backslashes, parentheses, I've tried reading some beginner's guide, but still trouble fixing this problem, do you have any tips where or what to read to learn more about sed? can you also help me with my problem? Note: I was tasked to use... (4 Replies)
Discussion started by: akopocpoypoy
4 Replies
set(n)							       Tcl Built-In Commands							    set(n)

__________________________________________________________________________________________________________________________________________________

NAME
set - Read and write variables SYNOPSIS
set varName ?value? _________________________________________________________________ DESCRIPTION
Returns the value of variable varName. If value is specified, then set the value of varName to value, creating a new variable if one does not already exist, and return its value. If varName contains an open parenthesis and ends with a close parenthesis, then it refers to an array element: the characters before the first open parenthesis are the name of the array, and the characters between the parentheses are the index within the array. Otherwise varName refers to a scalar variable. If varName includes namespace qualifiers (in the array name if it refers to an array element), or if varName is unqualified (does not include the names of any containing namespaces) but no procedure is active, varName refers to a namespace variable resolved according to the rules described under NAME RESOLUTION in the namespace manual page. If a procedure is active and varName is unqualified, then varName refers to a parameter or local variable of the procedure, unless varName was declared to resolve differently through one of the global, variable or upvar commands. EXAMPLES
Store a random number in the variable r: set r [expr {rand()}] Store a short message in an array element: set anAry(msg) "Hello, World!" Store a short message in an array element specified by a variable: set elemName "msg" set anAry($elemName) "Hello, World!" Copy a value into the variable out from a variable whose name is stored in the vbl (note that it is often easier to use arrays in practice instead of doing double-dereferencing): set in0 "small random" set in1 "large random" set vbl in[expr {rand() >= 0.5}] set out [set $vbl] SEE ALSO
expr(n), global(n), namespace(n), proc(n), trace(n), unset(n), upvar(n), variable(n) KEYWORDS
read, write, variable Tcl set(n)
All times are GMT -4. The time now is 04:25 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy