command to insert a record at a particular loaction


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users command to insert a record at a particular loaction
# 1  
Old 12-17-2008
command to insert a record at a particular loaction

Hi,

Is there any command to insert a line in between two lines?

My input data is as below:
1|ETG|63121387883|Alternate|Y
3|79.58|||GBP||
4|001137001
4|0011372
5|1021701
5|1021901
1|ETG|63121387884|Alternate|Y
3|79.58|||GBP||
4|001137001
5|1021702
5|1021802
1|ETG|63128363077|Alternate|Y
2|EN_GB||Electrogalvanize 0.5 m2 ( Renault )
2|FR_GB||Electrogalvanize 0.5 m2 ( Renault )
3|88.51|||GBP||
4|001137001
4|001137002
5|1021901
5|7040500
1|ETG|63128363078|Alternate|Y
3|88.51|||GBP||
4|001137001
5|1021702
5|1021722
1|ETG|63128363079|Alternate|Y
2|EN_GB||Electrogalvanize
4|001137005
5|2021901
5|8040500

I need to insert a record (2|||) only in between thoes records marked in red

My desired output is as below :
1|ETG|63121387883|Alternate|Y
2|||
3|79.58|||GBP||
4|001137001
4|0011372
5|1021701
5|1021901
1|ETG|63121387884|Alternate|Y
2|||
3|79.58|||GBP||
4|001137001
5|1021702
5|1021802
1|ETG|63128363077|Alternate|Y
2|EN_GB||Electrogalvanize 0.5 m2 ( Renault )
2|FR_GB||Electrogalvanize 0.5 m2 ( Renault )
3|88.51|||GBP||
4|001137001
4|001137002
5|1021901
5|7040500
1|ETG|63128363078|Alternate|Y
2|||
3|88.51|||GBP||
4|001137001
5|1021702
5|1021722
1|ETG|63128363079|Alternate|Y
2|EN_GB||Electrogalvanize
4|001137005
5|2021901
5|8040500

can any one help me in this regard?

Thanks in advance
# 2  
Old 12-17-2008
I feel, you need to write small code to do this. check echo manpage if you get anything...
Code:
info coreutils 'echo invocation'

- $nilesh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Insert field values in a record using awk command

Hi Friends, Below is my input file with "|" (pipe) as filed delimiter: My Input File: HDR|F1|F2||||F6|F7 I want to inser values in the record for field 4 and field 5. Expected output HDR|F1|F2||F4|F5|F6|F7 I am able to append the string to the end of the record, but not in between the... (3 Replies)
Discussion started by: Ajay Venkatesan
3 Replies

2. Programming

MYSQL - trigger update on record insert or update

Right I have a MYSQL database with table1 with 3 columns, colA, colB and colC. I want to combine the data in the 3 columns into a 4th column names col_comb. Here's the SQL command that works: UPDATE table1 SET `col_comb` = CONCAT( `colA` , ' - ', `colB` , ', ', `colC` ); So now I want this... (5 Replies)
Discussion started by: barrydocks
5 Replies

3. Shell Programming and Scripting

Insert a header record (tab delimited) in multiple files

Hi Forum. I'm struggling to find a solution for the following issue. I have multiple files a1.txt, a2.txt, a3.txt, etc. and I would like to insert a tab-delimited header record at the beginning of each of the files. This is my code so far but it's not working as expected. for i in... (2 Replies)
Discussion started by: pchang
2 Replies

4. Shell Programming and Scripting

How to insert a single quote to each record

I have a file as: 1 New used 1 used New I need o/p as: '1' 'New' 'used' '1' 'used' 'New' (12 Replies)
Discussion started by: karumudi7
12 Replies

5. Shell Programming and Scripting

Record all users' command

Hi experts, .history can record one user's own command history, but my request is, I want to record all users who run commands on that box, and export the commands to a file somewhere, which record the userid, time and full command. Is it possible? I just need for audit, and trace back, if... (3 Replies)
Discussion started by: newoz
3 Replies

6. Shell Programming and Scripting

MSQL insert record

Hi All, I have created a script to capture process run by the user & put into to mysql DB. But some how i am anot able to insert output of ps aux as below sting in mysql db. ######################################... (2 Replies)
Discussion started by: ajaincv
2 Replies

7. UNIX for Advanced & Expert Users

unix command : how to insert text at the cursor location via command line?

Hi, Well my title isn't very clear I think. So to understand my goal: I have a script "test1" #!/bin/bash xvkbd -text blabla with xbindkeys, I bind F5 key in order it runs my test1 script So when I press F5, test1 runs. I'm under Emacs/Vi and I press F5 in order to have "blabla" be... (0 Replies)
Discussion started by: xib.be
0 Replies

8. UNIX for Dummies Questions & Answers

sed insert command and variable expansion/command substitution

I know this script is crummy, but I was just messing around.. how do I get sed's insert command to allow variable expansion to show the filename? #!/bin/bash filename=`echo $0` /usr/bin/sed '/#include/ { i\ the filename is `$filename` }' $1 exit 0 (8 Replies)
Discussion started by: glev2005
8 Replies

9. Shell Programming and Scripting

How to copy particular record with cp command

Hi , I have a table of 5 records. I am using FOR condition in this table. Using FOR , I want to copy those particular record into someother file which satisfies the condition. How to use 'cp' command in this situation in UNIX For Ex No Prod Price Bar Code 1 Colgate 23 34564 col 2... (5 Replies)
Discussion started by: devmns
5 Replies

10. Shell Programming and Scripting

How to insert a record in fixed width flatfile

I have a fixed width flatfile with 5 columns, i will load file from oracle database to the flatfile for every 15 min at the end of the file, i want to insert a record by calling a shell script for inserting a record. please can any one help me. Thanks. (1 Reply)
Discussion started by: limou
1 Replies
Login or Register to Ask a Question