finding a numeric value in a file for replacement

Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers finding a numeric value in a file for replacement
# 1  
Old 06-28-2001
finding a numeric value in a file for replacement

thank u optimus,but one more might be do i get the value in the file that should be replaced..while running the script..its an numeric value..that i want to change..

when i used sed for replacement ie.

sed s/521000/100/p
with print option it is printing two times..why so...and how to get that 521000 from a file...

any body...please ...

can any one else give me the solution for this..if possible with the code...itz urgent pls...Smilie

hello kapil this is a script where we dont the the exact value of the number ...we need to get it at run time my dout is how to search for a particular number in a file to replace it...

Last edited by Babu; 06-30-2001 at 06:20 PM..
# 2  
Old 06-30-2001

If you want to search for a value in a file you find it using search option and futher if you want to replace it you can use the search and replace command.
now if you want to search 521000 and replace it with 100
then you can write a script file.

vi try.txt << !

Hope this works.

Last edited by kapilv; 07-21-2001 at 02:26 PM..
# 3  
Old 08-01-2001
Hello Babu

I had the same problem, and I got round it by using the cut option.

In my case I had a file with the following lines:
where the number would change. I used the command:

cut -d= -f2 -s [filename]

This sets the delimiter to "=" and then prints field 2, and only prints lines on which the delimiter is found.

Hope this helps,
# 4  
Old 08-01-2001
well on a command line you can pass arguments to your script.

use the vaiables $1 $2 $3 ...........


#script.ksh 521000 100

and in the script you could have something like

sed 's/$1/$2/g'
# 5  
Old 08-01-2001

if u can edit this file using vi do it, then....

:g/old_value/s//new_value/g (enter)

and every "old_value" will be changed into the "new_value" all file along.

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Parsing of Char and Numeric in a file

Hi All, i'm working on some report and currently have this plain text file generated. server_name1|sdfd1deal | 1048572| 1040952| 99| 207| 1| 1 server_name1|dba1dbs | 83886048| 40730796| 48| 5762| 22764| 8... (4 Replies)
Discussion started by: fedora132010
4 Replies

2. Shell Programming and Scripting

File Replacement Help

Hi all, I have two files, one is a base file and the other is a dependency file. I need to replace a section in the base file (File A) with a section from the dependency file (File B), for example: File A: ... <TagName> <TagA>MyBaseFile</TagA> <TagB>MyBaseFileID</TagB> </TagName>... (5 Replies)
Discussion started by: muay_tb
5 Replies

3. Shell Programming and Scripting

Finding BEGINNING & ENDING positions of sequentially increasing sublists from a perl numeric array

I have got an Perl array like: @array = (1,2,3,4,5,6,1,2,3,4,1,2,1,2,3,4,5,6,7,8,9...............) This numeric sequence will be always sequentially increasing, unless it encounters, The beginning of the new sequentially increasing numeric sequence. SO in this array we get sequentially... (5 Replies)
Discussion started by: teknokid1
5 Replies

4. UNIX for Dummies Questions & Answers

Find and Replace random numeric value with non-numeric value

Can someone tell me how to change the first column in a very large 17k line file from a random 10 digit numeric value to a non numeric value. The format of lines in the file is: 1702938475,SNU022,201004 the first 10 numbers always begin with 170 (6 Replies)
Discussion started by: Bahf1s
6 Replies

5. Shell Programming and Scripting

How to check if a column is having a numeric value or not in a file?

Hi, I want to know, how we find out if a column is having a numeric value or not. For Example if we have a csv file as ASDF,QWER,GHJK,123,FGHY,9876 GHTY,NVHR,WOPI,623,HFBS,5386 we need to find out if the 4th and 6th column has muneric value or not. Thanks in advance Keerthan (9 Replies)
Discussion started by: keerthan
9 Replies

6. Shell Programming and Scripting

How to check if the file contains only numeric values

How to check if the file contains only numeric values. I don't want to read entire file it eats lot of cpu Or any way which consumes less memory n cpu.. Please suggest -S (2 Replies)
Discussion started by: sunilmenhdiratt
2 Replies

7. Shell Programming and Scripting

PERL:How to convert numeric values txt file to PACKED DECIMAL File?

Is there any way to convert numeric values txt file to PACKED DECIMAL File using PERL. Regards, Alok (1 Reply)
Discussion started by: aloktiwary
1 Replies

8. Shell Programming and Scripting

Replacement of text in a file

Hi , I have some data in my file(properties.txt) like this. # agent.dmp.Location= I need to relpace the agent.dmp.location with agent.dmp.Location = /opt/VRTS/vxvm I am using the follwing to replace the string AGENT_NAME=snmp... (2 Replies)
Discussion started by: raghu.amilineni
2 Replies

9. Shell Programming and Scripting

Perl code to differentiate numeric and non-numeric input

Hi All, Is there any code in Perl which can differentiate between numeric and non-numeric input? (11 Replies)
Discussion started by: Raynon
11 Replies

10. Shell Programming and Scripting

How To Add Numeric Data of A file

Dear All, I want to add Numeric data of my file called temp_f41. But I am not getting how to add them, My File data are in following format of: 10 39 53 05 37 54 Plz send me code for this Thanks Nishant :mad: (3 Replies)
Discussion started by: krishna_sicsr
3 Replies
Login or Register to Ask a Question