How to replicated records using sed


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to replicated records using sed
# 1  
Old 11-12-2008
How to replicated records using sed

I need to generate exactly 102 duplicates in a file using sed.

Here's an example of my input:
Grid-ref = 1, 148
Grid-ref = 1, 311
Grid-ref = 1, 428


I need:
Grid-ref = 1, 148
Grid-ref = 1, 148
Grid-ref = 1, 148
Grid-ref = 1, 148
... repeated 102 times, then
Grid-ref = 1, 311
Grid-ref = 1, 311
Grid-ref = 1, 311
... repeated 102 times, then record 3, etc.

Any ideas using either sed (preferably), awk or ksh?

thanks
# 2  
Old 11-12-2008
Code:
 awk '{for(i=1;i++<=v;)print}' v=102 file

# 3  
Old 11-12-2008
You rock!
Much thanks.
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Format data by consolidating replicated obs

Please assist with the following. I have readings R1, R2,..Rn from plants from different fields , sometimes replicated. I need to first consolidate the replicates by their mean value per plant per field. Then I need to reformat the data by partially transposing it. The missing values... (3 Replies)
Discussion started by: jianp83
3 Replies

2. Solaris

Working with disk sets from replicated LUNs

Hi everybody We have a Sun Cluster with two nodes, connected to a number of SAN disks over fiber cables. We made SVM disk sets on those disks for our application needs. Now we constructed another site in another metropolitan area, but with only one node (no cluster), and connected it to the main... (2 Replies)
Discussion started by: abohmeed
2 Replies

3. Shell Programming and Scripting

Preventing script from being replicated on a defined number of hosts

ok. i have an extensive program written predominantly in borne shell. i have to give an "evaluation" copy of this program to a user so she can test it out and see if she wants it. problem is, i dont have an evaluation copy. and even if i did, im worried the evaluation copy can be edited to... (8 Replies)
Discussion started by: SkySmart
8 Replies

4. Shell Programming and Scripting

Display records between two search strings using sed

I have input file like AAA AAA CCC CCC CCC EEE EEE EEE EEE FFF FFF GGG GGG i was trying to retrieve data between two strings using sed. sed -n /CCC/,/FFF/p input_file Am getting output like CCC CCC CCC (1 Reply)
Discussion started by: NareshN
1 Replies

5. UNIX for Dummies Questions & Answers

Turning to SED to select specific records

Hi All, I am looking for a simple concise solution most likely using sed to process the following 4 rows of data from the same record and only keeps it if the second record satisfy certain critea such as surname matches up to smith or jackson: John (firstname) Smith (surname) ... (21 Replies)
Discussion started by: gjackson123
21 Replies

6. Shell Programming and Scripting

Finding some records with sed command

Hi for all! sorry guys for my dumb question, but I'm really need help so, we have file with many many fields, like this one: 201001002359 blablabla 87654321 201001002359 123,56 77272588300 blablabla/123 91823778544and I wrote awk command awk '{if($6~/(2588300|2580000|2587021)$/)print}'so,... (8 Replies)
Discussion started by: shizik
8 Replies

7. Shell Programming and Scripting

deleting text records with sed (sed paragraphs)

Hi all, First off, Thank you all for the knowledge I have gleaned from this site! Deleting Records from a text file... sed paragraphs The following code works nearly perfect, however each time it is run on the log file it adds a newline at the head of the file, run it 5 times, it'll have 5... (1 Reply)
Discussion started by: Festus Hagen
1 Replies

8. UNIX for Dummies Questions & Answers

logging deleted records by sed

Hi, I want to use the sed command to delete some lines in a file and I was wondering whether there is a possibility of knowing which lines are deleted, or at least which line numbers. Thanks (4 Replies)
Discussion started by: vanagreg
4 Replies

9. Shell Programming and Scripting

How to delimit a flat file with records with SED

Hi gurus, hoping someone can help with a sed line that can do the following... I have a flat file with about 1000 records, but in order to import into openoffice spreadsheet, I need to create a delimited file. I'd like to do 2 things with the SED command: 1- add a pipe character "|" at the end... (4 Replies)
Discussion started by: RogCor
4 Replies
Login or Register to Ask a Question