Mulitple rows update by sed command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Mulitple rows update by sed command
# 1  
Old 09-29-2011
Mulitple rows update by sed command

Hi All,

I need to update 2 rows in my file. But i can do only one row update by sed command. Please help me how can i change mutltiple rows in single sed commana

my i/p file: (example.txt)
Code:
record
  integer (10) present_id;
  string (10) first_name;
  string (10) last_name;
  string (11) mobile_no;
end;

My out put would be:
Code:
ebcdic record
  string (12) referid_id;
  string (10) first_name;
  string (10) last_name;
  string (11) mobile_no;
end;

I using command: cat example.txt | sed -e 's/record/ebcdic record/'
but through this command i changed first line only.

Please help me in this.

Thnaking in advance......

Regards,
Dathu

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 09-29-2011 at 05:28 PM..
# 2  
Old 09-29-2011
What about this:
Code:
sed -e 's/record/ebcdic record/' -e 's/integer (10) present_id;/string (12) present_id;/' Inp_File > Out_File

This User Gave Thanks to Shell_Life For This Post:
# 3  
Old 09-29-2011
Thanks, its working....
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk or sed? rows text to co

Hello Friends! I would like to help the masters ... I have a file with the entry below and would like a script for that output: Input file: 001 1 01-20152142711532-24S 1637909825/05/2015BAHIA SERVICOS R F, ... (1 Reply)
Discussion started by: He2
1 Replies

2. UNIX for Dummies Questions & Answers

Mysql: How to update value in 27000 rows?

Hello, some member created 27000 posts in wrong section (lol :D) so i need to edit all his entries to get new section ID. SELECT * FROM `phpbb_topics` WHERE `topic_first_poster_name` LIKE "%ozerway%"; this will select all his topics... the column with forum id is named "forum_id" and... (3 Replies)
Discussion started by: postcd
3 Replies

3. Shell Programming and Scripting

ksh sed - Extract specific lines with mulitple occurance of interesting lines

Data file example I look for primary and * to isolate the interesting slot number. slot=`sed '/^primary$/,/\*/!d' filename | tail -1 | sed s'/*//' | awk '{print $1" "$2}'` Now I want to get the Touch line for only the associate slot number, in this case, because the asterisk... (2 Replies)
Discussion started by: popeye
2 Replies

4. UNIX and Linux Applications

Script to delete few rows from a file and then update header

HJKL1Name00014300010800000418828124201 L201207022012070228XAM 00000000031795404 001372339540000000000000000000000 COOLTV KEYA Zx00 xI-50352202553 00000000 00000000 G000000000000 00000000 ... (10 Replies)
Discussion started by: mirwasim
10 Replies

5. Programming

How to do a "sed-like" update command in mysql?

Dear mates, imagine a table with only one column and 10 rows containing 5 yahoo.de and 5 gmail.com email addressess. mail1@yahoo.de mail2@yahoo.de mail3@yahoo.de mail4@yahoo.de mail5@yahoo.de mail1@gmail.com mail2@gmail.com mail3@gmail.com mail4@gmail.com mail5@gmail.com How could I... (2 Replies)
Discussion started by: pseudocoder
2 Replies

6. AIX

Rows manupulation using AWK or sed

Hi Everyon, I am stuck in a script.I have a file named file1.txt as given below: It contains 2 columns-count and filename. cat file1.txt count filename 100 A_new.txt 1000 A_full.txt 1100 B_new.txt 2000 B_full.txt 1100 C_new.txt 2000 C_full.txt ................... ..................... (10 Replies)
Discussion started by: rajsharma
10 Replies

7. UNIX for Dummies Questions & Answers

how to capture no. of rows updated in update sql in unix db2

hi, i am a new user in unix..and we have unix db2. i want to capture the no. of rows updated by a update db2 sql statement and redirect into a log file. I've seen db2 -m...but not sure how the syntax should be. The update sql that I'm going to run is from a file... Can you please share... (1 Reply)
Discussion started by: j_rymbei
1 Replies

8. Web Development

Mysql question: Best way to update a column containing 8 million rows

Hi all, I was wondering if anyone knew a good/safe way to update a single column in a table that could contain upto 8 million rows... simple command like: UPDATE set blah=foo where bar=XXX; I will be running this on tables being written to and tables that have already been created. ... (3 Replies)
Discussion started by: muay_tb
3 Replies

9. Shell Programming and Scripting

get text between two special rows ?(awk or sed)?

Hello, I've the follwing text: gfdgfg -------------------------------- dfgfdgdfg fdgfdgfdgdgf fdgf ------------------------------ f g gdgf a constant string that i know --------------------------------------------- data I want to have data I want to have data I want to have data I... (16 Replies)
Discussion started by: eric_
16 Replies

10. Shell Programming and Scripting

awk with mulitple FS

Hi, I would like to get 5th field from this output using FS. Filesystem 1024-blocks Used Available Capacity Mounted on 172.29.138.222:/vol/vol0 311936256 2565248 309371008 1% /tmp/test My command is df -kP | awk ' BEGIN { FS="" ; } { print $5 ; } ' For some... (5 Replies)
Discussion started by: phamp008
5 Replies
Login or Register to Ask a Question