Update specific lines in a file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Update specific lines in a file
# 1  
Old 11-15-2005
Update specific lines in a file

Hi all,
I want to add a special character ^M to a line, if the line starts with ORDE.
All the other lines should remain unchanged.
Is there sed or other UNIX function who can do this.

Thanx in advance
Auke Quist
# 2  
Old 11-15-2005
Question

not really sure how to use grep but maybe grep for the line with ORDE in it. there is something in man sed that might help its something like [2addr]H Append a newline character followed by the contents of the pattern space to hold the space. I think that could help you maybe? idk just trying to learn by giving suggestions, doing a little research, and seeing if they work
# 3  
Old 11-15-2005
This helps a bit, any other suggestions still welcome
# 4  
Old 11-15-2005
Awk:
Code:
/ORDE/ { $0 = $0 "\r" }
{ print }

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Update a specific field in file with Variable value based on other Key Word

I have an input file with A=xyz B=pqr I would want the value in Second Field (xyz or pqr) updated with a value present in Shell Variable based on the value passed in the first field. (A or B ) while read line do NEW_VALUE = `some functionality done on $line` If $line=First Field-... (1 Reply)
Discussion started by: infernalhell
1 Replies

2. Shell Programming and Scripting

awk to update specific value in file with match and add +1 to specific digit

I am trying to use awk to match the NM_ in file with $1 of id which is tab-delimited. The NM_ will always be in the line of file that starts with > and be after the second _. When there is a match between each NM_ and id, then the value of $2 in id is substituted or used to update the NM_. Each NM_... (3 Replies)
Discussion started by: cmccabe
3 Replies

3. UNIX for Dummies Questions & Answers

Quick UNIX command to display specific lines in the middle of a file from/to specific word

This could be a really dummy question. I have a log text file. What unix command to extract line from specific string to another specific string. Is it something similar to?: more +/"string" file_name Thanks (4 Replies)
Discussion started by: aku
4 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. AIX

how to find which program that update a specific file

Hello Would you tell me how to find which program that update a specific file? I am implementing migration project. My machines OS are AIX. It is because lack of documentation, some program cannot working properly on new machine. We found the root cause of this problem is that some data... (4 Replies)
Discussion started by: cstsang
4 Replies

6. Shell Programming and Scripting

Extracting specific lines of data from a file and related lines of data based on a grep value range?

Hi, I have one file, say file 1, that has data like below where 19900107 is the date, 19900107 12 144 129 0.7380047 19900108 12 168 129 0.3149017 19900109 12 192 129 3.2766666E-02 ... (3 Replies)
Discussion started by: Wynner
3 Replies

7. 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

8. Shell Programming and Scripting

Substitute specific lines with lines from another file

Hello All, I am new to this forum. I am currently facing a problem in manipulating files. I have two files called old-matter and new-matter # cat old-matter abc: this, is a, sample, entry byi: white board, is white in color rtz: black, board is black qty: i tried, a lot asd: no... (1 Reply)
Discussion started by: rahmathulla
1 Replies

9. UNIX for Dummies Questions & Answers

how to display specific lines of a specific file

are there any basic commands that can display lines 99 - 101 of the /etc/passwd file? I'm thinking use of head and tail, but I forget what numbers to use and where to put /etc/passwd in the command. (2 Replies)
Discussion started by: raidkridley
2 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