Update a particular line in a file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Update a particular line in a file
# 1  
Old 03-11-2010
Update a particular line in a file

Hii to all..

I have a file stud.lst

bash-3.1$ cat stud.lst
NO NMAE DOB 10 +2 BE AVG
075 syam saksena 12/12/55 500 398 550 48.26
099 sachin 11/05/47 450 500 600 51.66
300 mohan kumar 19/04/43 500 600 700 60.00
100 john 12/12/52 800 750 700 75.00
125 anil 03/09/38 800 700 750 75.00
101 sourav 30/08/56 600 780 900 76.00

I wanna give provision to change the personal details... with this file in a shell script





echo -n "record u wanna change, give student name :"
read name
grep $name stud.lst #shows record need to update
echo "Enter new data like no name dob 10 12 BE "

# here I've to read the data and calculate average and update the whole line to file....

# How to do it....


Thanking u...Smilie
# 2  
Old 03-11-2010
Is this another homework question?

Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.

Please review the rules, which you agreed to when you registered, if you have not already done so.

More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.

If you did post homework in the main forums, please review the guidelines for posting homework and repost.

Thank You.

The UNIX and Linux Forums.
# 3  
Old 03-11-2010
you may remove this thread
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

awk to update file with partial matching line in another file and append text

In the awk below I am trying to cp and paste each matching line in f2 to $3 in f1 if $2 of f1 is in the line in f2 somewhere. There will always be a match (usually more then 1) and my actual data is much larger (several hundreds of lines) in both f1 and f2. When the line in f2 is pasted to $3 in... (4 Replies)
Discussion started by: cmccabe
4 Replies

2. Shell Programming and Scripting

Find and update line in xml file

Hi, I have a xml file that I need to modify 1 line to change some value from 2 to 10 (or any number). Sample input: <!-- some text here> . . . <message:test name="ryan"> <message:sample-channel charset="UTF-8" max-value="2" wait="20"> ... (5 Replies)
Discussion started by: brichigo
5 Replies

3. Shell Programming and Scripting

sed insert new line does not update file

Hi all, I have a file called "text.cpp" with the first line of "1" afterwards I tried in Ubuntu to type the following sed '12iasdasdasdasdsad' test.cpp > output.txt however when I tried to see the result of output.txt #cat output.txt 1 why is the line 12 is not updated to the... (6 Replies)
Discussion started by: peuceul
6 Replies

4. Shell Programming and Scripting

Update specific field in a line of text file

I have a text file like this: subject1:LecturerA:10 subject2:LecturerA:40 if I was given string in column 1 and 2 (which are subject 1 and LecturerA) , i need to update 3rd field of that line containing that given string , which is, number 10 need to be updated to 100 ,for example. The... (6 Replies)
Discussion started by: bmtoan
6 Replies

5. Shell Programming and Scripting

Grep the word from pattern line and update in subsequent lines till next pattern line reached

Hi, I have got the below requirement. please suggest. I have a file like, Processing Item is: /data/ing/cfg2/abc.txt /data/ing/cfg3/bgc.txt Processing Item is: /data/cmd/for2/ght.txt /data/kernal/config.klgt.txt I want to process the above file to get the output file like, ... (5 Replies)
Discussion started by: rbalaj16
5 Replies

6. UNIX for Dummies Questions & Answers

Command to update last line.

Hi, I need to replace the record count which is in the last line of the text file to a new record count. The file is a fixed length file, and whole file is list of numbers and the last line looks like this. 9#EOF# 00000000000000000016 ... (9 Replies)
Discussion started by: shinny
9 Replies

7. Shell Programming and Scripting

Update single line

Hi everyone i need one help don't know whether it is simple or difficult but not able to solve it. here is the problem suppose my code is time_def=3 r=0 while ] do echo "time left is $time_def " ((time_def=time_def-1)) done and the output is time left is 3 time left... (6 Replies)
Discussion started by: aishsimplesweet
6 Replies

8. UNIX for Dummies Questions & Answers

Python update already printed line.

Hi. I have a basic script in python that outputs like this.. $ ./test.py 1% 2% 3% 4% 5% 6% 7% 8% 9% 10% ... But how can I make it so the output stays in 1 line? So it would look something like this.. $ ./test.py 10% (1 Reply)
Discussion started by: cbreiny
1 Replies

9. Shell Programming and Scripting

Update a specific line in a file while reading sequentially

All, I know this is a very naive question but I could not find a way to get this working! I have a file with values like input.file Value1 Value2 server1/mylogin,mypasswd Value3 Value4 And in my code, I am reading the file line by line and processing it. #! /bin/ksh... (6 Replies)
Discussion started by: bharath.gct
6 Replies

10. Shell Programming and Scripting

SED: Update Last Line with Number Lines in File

Hi, I have to update last line of a text file with the number of lines in that file. This last line will have text such as 0.0000 and I should replace this with number lines. If lines are 20 then it should be replaced with 00020. Any sed or awk cmd help would be appreciated (3 Replies)
Discussion started by: bmkux
3 Replies
Login or Register to Ask a Question