08-20-2010
how to add duplicate lines
Hi,
I have a file that looks like this:
a_X data
a_Y data
b data
c data
d_X data
d_Y data
I **want** to duplicate the lines without the _X and _Ys. In other words, I want it to look like this
a_X data
a_Y data
b data
b data
c data
c data
d_X data
d_Y data
I have no idea how to go about this. Another detail (or complication) is that there is a header and a footer that I would prefer not to be duplicated. Is there anyway to restrict this operation to just occur between the a line that says "matrix" and ";end;". This last part is really not necessary, but would be helpful.
I have the feeling that something like sed would be good, but I can't figure it out!
Thanks!
Mikey
10 More Discussions You Might Find Interesting
1. UNIX for Advanced & Expert Users
Hi,
I have a file with duplicate lines in it. I want to keep only the duplicate lines and delete the non duplicates. Can some one please help me?
Regards
Narayana Gupta (3 Replies)
Discussion started by: guptan
3 Replies
2. Shell Programming and Scripting
Hi Guys and Girls
I'm having trouble outputing from a sorted file... i have a looooong list of PVIDs and need to only output only those which occur 4 times!! Any suggestions?
ie I need to uniq (but not uniq (i've been through the man pg) this:
cat /tmp/disk.out|awk '{print $3}' |grep -v... (6 Replies)
Discussion started by: serm
6 Replies
3. UNIX for Dummies Questions & Answers
Hi all,
I have a tab-delimited file and want to remove identical lines, i.e. all of line 1,2,4 because the columns are the same as the columns in other lines. Any input is appreciated.
abc gi4597 9997 cgcgtgcg $%^&*()()*
abc gi4597 9997 cgcgtgcg $%^&*()()*
ttt ... (1 Reply)
Discussion started by: dr_sabz
1 Replies
4. Shell Programming and Scripting
Hi All,
I am trying to remove the duplicate entries in a file and print them just once. For example, if my input file has:
00:44,37,67,56,15,12
00:44,34,67,56,15,12
00:44,58,67,56,15,12
00:44,35,67,56,15,12
00:59,37,67,56,15,12
00:59,34,67,56,15,12
00:59,35,67,56,15,12... (7 Replies)
Discussion started by: faiz1985
7 Replies
5. Shell Programming and Scripting
I have a file where some of the lines are duplicates.
How do I use bash to print all the lines that have duplicates? (2 Replies)
Discussion started by: locoroco
2 Replies
6. UNIX for Advanced & Expert Users
Hi All,
I have a very huge file (4GB) which has duplicate lines. I want to delete duplicate lines leaving unique lines. Sort, uniq, awk '!x++' are not working as its running out of buffer space.
I dont know if this works : I want to read each line of the File in a For Loop, and want to... (16 Replies)
Discussion started by: krishnix
16 Replies
7. Shell Programming and Scripting
Hello,
I'm trying to write an script that in a txt with lines with 2 or more columns separated by commas, like
hello, one, two
bye, goal
first, second, third, fourth
hard, difficult.strong, word.line
will create another in which if a line has more than 2 columns, it will have another... (4 Replies)
Discussion started by: clinisbud
4 Replies
8. UNIX for Dummies Questions & Answers
I have a file with following data
A
B
C
I would like to print like this n times(For eg:5 times)
A
B
C
A
B
C
A
B
C
A
B
C
A (7 Replies)
Discussion started by: nsuresh316
7 Replies
9. Shell Programming and Scripting
Dear All,
I have a two-column data file and want to duplicate data in second column w.r.t. first column.
My file looks like:
2 5.672
1 3.593
3 8.260
...
And the desired format:
5.672
5.672
3.593
8.260
8.260
8.260
...
How may I do so please? I appreciate any help you may... (2 Replies)
Discussion started by: sxiong
2 Replies
10. Shell Programming and Scripting
Hi All,
I am storing the result in the variable result_text using the below code.
result_text=$(printf "$result_text\t\n$name") The result_text is having the below text. Which is having duplicate lines.
file and time for the interval 03:30 - 03:45
file and time for the interval 03:30 - 03:45 ... (4 Replies)
Discussion started by: nalu
4 Replies
LEARN ABOUT MOJAVE
uri::data5.18
URI::data(3) User Contributed Perl Documentation URI::data(3)
NAME
URI::data - URI that contains immediate data
SYNOPSIS
use URI;
$u = URI->new("data:");
$u->media_type("image/gif");
$u->data(scalar(`cat camel.gif`));
print "$u
";
open(XV, "|xv -") and print XV $u->data;
DESCRIPTION
The "URI::data" class supports "URI" objects belonging to the data URI scheme. The data URI scheme is specified in RFC 2397. It allows
inclusion of small data items as "immediate" data, as if it had been included externally. Examples:
data:,Perl%20is%20good
data:image/gif;base64,R0lGODdhIAAgAIAAAAAAAPj8+CwAAAAAI
AAgAAAClYyPqcu9AJyCjtIKc5w5xP14xgeO2tlY3nWcajmZZdeJcG
Kxrmimms1KMTa1Wg8UROx4MNUq1HrycMjHT9b6xKxaFLM6VRKzI+p
KS9XtXpcbdun6uWVxJXA8pNPkdkkxhxc21LZHFOgD2KMoQXa2KMWI
JtnE2KizVUkYJVZZ1nczBxXlFopZBtoJ2diXGdNUymmJdFMAADs=
"URI" objects belonging to the data scheme support the common methods (described in URI) and the following two scheme-specific methods:
$uri->media_type( [$new_media_type] )
Can be used to get or set the media type specified in the URI. If no media type is specified, then the default
"text/plain;charset=US-ASCII" is returned.
$uri->data( [$new_data] )
Can be used to get or set the data contained in the URI. The data is passed unescaped (in binary form). The decision about whether to
base64 encode the data in the URI is taken automatically, based on the encoding that produces the shorter URI string.
SEE ALSO
URI
COPYRIGHT
Copyright 1995-1998 Gisle Aas.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
perl v5.18.2 2012-02-11 URI::data(3)