bipinajith's proposal works as long as all of the allele= and alleles= entries are in the 2nd field in the input lines, and all of the allele= entries come after the alleles= entry, except that it doesn't put the requested "/" between allele= entries when more than one is present. It also provides an extra leading newline that wasn't requested.
The following should work as requested no matter what order they are in nor which fields contain allele and alleles entries even if multiple entries appear on the same line. It will also print multiple alleles= entries if they occur using a comma to separate subsequent occurrences:
Code:
awk -F ' *| *' 'function pr() {
if(r) printf("%s %s %s\n", r, p, s)
p = r = s = ""
n1 = 1
}
NF == 0 {pr()
next
}
n1 { n1 = 0
r = $1
}
/allele/ {for(i = 1; i <= NF; i++) {
if($i ~ /allele=/)
s = (s ? s "/" : "") substr($i, index($i, "=") + 1)
if($i ~ /alleles=/)
p = (p ? p "," : "") substr($i, index($i, "=") + 1) }
}END { pr()}' input
As always, if you're using a Solaris system, use /usr/xpg4/bin/awk or nawk instead of awk.
This User Gave Thanks to Don Cragun For This Post:
Hi
I want to extract certain text between two line numbers like
23234234324 and
54446655567567
How do I do this with a simple sed or awk command?
Thank you.
---------- Post updated at 06:16 PM ---------- Previous update was at 05:55 PM ----------
found it:
sed -n '#1,#2p'... (1 Reply)
Hi,
I got a long list of contents:
>sequence_1
ASSSSSSSSSSSDDDDDDDDDDDCCCCCCC
ASDSFDFFDFDFFWERERERERFSDFESFSFD
>sequence_2
ASDFDFDFFDDFFDFDSFDSFDFSDFSDFDSFASDSADSADASD
ASDFFDFDFASFASFASFAFSFFSDASFASFASFAFS
>sequence_3
VEDFGSDGSDGSDGSDGSDGSDGSDG
dDFSDFSDFSDFSDFSDFSDFSDFSDF... (2 Replies)
Hi,
I need to extract <APPNUMBER> tag alone, if the <college> haas IIT Chennai value. college tag value will have spaces embedded. Those spaces should not be suppresses.
My Source file
<Record><sno>1</sno><empid>E0001</empid><name>Rejsh suderam</name><college>IIT ... (3 Replies)
Hello,
I'm trying to code a bash script and I was wondering how to extract a specific line from a stream.
E.g.
My file "file" contains three lines and i'd like to find a function f which returns after execution a specific line like the second line, which would be :
f(file, 2) = Second... (4 Replies)
Hi guys,
I have txt file and I would need to extract all the contents between specific line numbers.
Line 1: apple
Line 2: orange
Line 3: mango
Line 4: grapes
Line 5: pine apple
I need to extract the content between line 2 and 4, including the contents of Line 2 and 4 so the ouput... (2 Replies)
Say the input was as follows:
Brat 20 x 1000 32rf
Pour 15 p 1621 05pr
Dart 10 z 1111 22xx
My program prompts for an input, what I want is to use the input to locate a specific field. Like if I type in, "Pou" then it would return "Pour" and just "Pour"
I currently have this line but it is... (6 Replies)
Hi All,
I'm trying to figure out which are the trusted-ips and which are not using a script file.. I have a file named 'ip-list.txt' which contains some ip addresses and another file named 'trusted-ip-list.txt' which also contains some ip addresses. I want to read a line from... (4 Replies)
Hi guys,
I have been trying to do this, but... no luck so maybe you can help me.
I have a line like this:
Total Handled, Received, on queue Input Mgs: 140 / 14 => 0
I need to, get the number after the / until the =, to get only 14 .
Any help is greatly appreciated.
Thanks, (4 Replies)
Hi, I am trying to use an awk command to replace specific character positions on a line beginning with 80 with contents of another file.
The line beginning with 80 in file1 is as follows:
I want to replace the 000000000178800 (positions 34 - 49) on this file with the contents of... (2 Replies)
Hi
This is my first post and I'm just a beginner. So please be nice to me.
I have a couple of html files where a pattern beginning with "http://www.site.com" and ending with "/resource.dat" is present on every 241st line. How do I extract this to a new text file?
I have tried sed -n 241,241p... (13 Replies)
Discussion started by: dejavo
13 Replies
LEARN ABOUT DEBIAN
dtrx
DTRX(1)DTRX(1)NAME
dtrx - cleanly extract many archive types
SYNOPSIS
dtrx [OPTIONS] ARCHIVE [ARCHIVE ...]
DESCRIPTION
dtrx extracts archives in a number of different formats; it currently supports tar, zip (including self-extracting .exe files), cpio, rpm,
deb, gem, 7z, cab, rar, and InstallShield files. It can also decompress files compressed with gzip, bzip2, lzma, or compress.
In addition to providing one command to handle many different archive types, dtrx also aids the user by extracting contents consistently.
By default, everything will be written to a dedicated directory that's named after the archive. dtrx will also change the permissions to
ensure that the owner can read and write all those files.
To run dtrx, simply call it with the archive(s) you wish to extract as arguments. For example:
$ dtrx coreutils-5.*.tar.gz
OPTIONS
dtrx supports a number of options to mandate specific behavior:
-r, --recursive
With this option, dtrx will search inside the archives you specify to see if any of the contents are themselves archives, and
extract those as well.
--one, --one-entry
Normally, if an archive only contains one file or directory with a name that doesn't match the archive's, dtrx will ask you how to
handle it. With this option, you can specify ahead of time what should happen. Possible values are:
inside Extract the file/directory inside another directory named after the archive. This is the default.
rename Extract the file/directory in the current directory, and then rename it to match the name of the archive.
here Extract the file/directory in the current directory.
-o, --overwrite
Normally, dtrx will avoid extracting into a directory that already exists, and instead try to find an alternative name to use. If
this option is listed, dtrx will use the default directory name no matter what.
-f, --flat
Extract all archive contents into the current directory, instead of their own dedicated directory. This is handy if you have multi-
ple archive files which all need to be extracted into the same directory structure. Note that existing files may be overwritten
with this option.
-n, --noninteractive
dtrx will normally ask the user how to handle certain corner cases, such as how to handle an archive that only contains one file.
This option suppresses those questions; dtrx will instead use sane, conservative defaults.
-l, -t, --list, --table
Don't extract the archives; just list their contents on standard output.
-m, --metadata
Extract the metadata from .deb and .gem archives, instead of their normal contents.
-q, --quiet
Suppress warning messages. Listing this option twice will cause dtrx to be silent.
-v, --verbose
Show the files that are being extracted. Listing this option twice will cause dtrx to print debugging information.
--help Display basic help.
--version
Display dtrx's version, copyright, and license information.
AUTHOR
Brett Smith <brettcsmith@brettcsmith.org>
COPYRIGHT
dtrx 6.5 is copyright (C) 2006-2009 Brett Smith and others. Feel free to send comments, bug reports, patches, and so on. You can find the
latest version of dtrx on its home page at <http://www.brettcsmith.org/2007/dtrx/>.
dtrx is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER-
CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program; if not, see <http://www.gnu.org/licenses/>.
6.5 2009-07-04 DTRX(1)