10-20-2011
"END" is a clause that is executed after whole file is processed. All the variables that were created during processing of the file are accessible there, so when AWK reads last line into $0, it is still there when executing "END"
![Wink Smilie](https://www.unix.com/images/smilies/wink.gif)
This User Gave Thanks to bartus11 For This Post:
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi,
I have these out put field seperator changed to "|" in my awk command, but it didn't give me the result.
Can someone help me find out why?
=======================================
/bin/awk 'BEGIN { OFS="|" } { print $0 }' list.tmp.$$ > listtmp.$$
=======================================... (1 Reply)
Discussion started by: whatsfordinner
1 Replies
2. Shell Programming and Scripting
OFS is inbuild command in awk.
I have a file file.txt
abc : def : ghi
jkl : mno: pqr
stu : vwx :yzz
code i used:
awk -F ":" 'BEGIN {OFS="|"} {print $1,$2}' file.txt
output:
abc def
jkl mno
stu vwx
but as i have used OFS="|" and i am expecting output as:
abc | def
jkl... (4 Replies)
Discussion started by: salil2012
4 Replies
3. Shell Programming and Scripting
Hi All,
I have a comma seperated delimited file with 10 columns. I need to convert it into TAB seperated delimited file.
awk -F"," '{print $1"\t"$2"\t"$3"\t"$4"\t"$5"\t"$6"\t"$7"\t"$8"\t"$9"\t"$10}' a.txt >> b.txt
how to use OFS to get the same output. I have tried by googling, but it... (5 Replies)
Discussion started by: Amit.Sagpariya
5 Replies
4. Shell Programming and Scripting
Hi,
I am trying to parse regular XML file where I have to reduce number of decimal points in some xml elements. I am using following AWK command to achive that :
#!/bin/ksh
EDITCMD='BEGIN { FS = ""; OFS=FS }
{
if ( $3 ~ "*\\.*" && length(substr($3,1+index($3,"."))) == 15 ) {... (4 Replies)
Discussion started by: martin.franek
4 Replies
5. Shell Programming and Scripting
Hi Im trying to tidy up the output of a who command when it writes to a log, everything I've tried doesnt seem to work though, any help would be massively appreciated. Im using the awk command to set the OFS as tab.
#!/bin/bash
who >> /export/home/tjmoore/logusers
awk -F 'BEGIN... (3 Replies)
Discussion started by: 02JayJay02
3 Replies
6. Shell Programming and Scripting
Hi, Could anyone tell me what Im doing wrong here any help will be much appreciated
#!/bin/bash
ls -ltr /export/home/tjmoore > /export/home/tjmoore/log100
awk -F " " /export/home/tjmoore/log100 'BEGIN {OFS="\t";} {print $1,$2,$3,$4,$5,
$6,$7,$8,$9;}' > /export/home/tjmoore/log1001
I... (9 Replies)
Discussion started by: 02JayJay02
9 Replies
7. UNIX for Dummies Questions & Answers
Hello,
I have an issue with adding commas as delimiters in this scenario:
cat xtr3.rpl|head -5|awk 'BEGIN {OFS=","} {print $1,$2,$3,$4}'
Produces this output:
00530083,0000000471,000000000000.00,000000000000.00
00530085,0000000471,000000000000.00,000000000000.00... (10 Replies)
Discussion started by: MIA651
10 Replies
8. Shell Programming and Scripting
file:
sasa|asasa|asasa|asas
erer|Erer|rere|ererer
Output needed :
sasa:asasa:asasa:asas
erer:Erer:rere:ererer
Im getting output, when i use the $1,$2.
awk -F'|' 'BEGIN{OFS=":";} {print $1,$2; }' file
Output :
sasa:asasa
erer:Erer
But when i need the whole column, i... (5 Replies)
Discussion started by: Ramesh M
5 Replies
9. Shell Programming and Scripting
Hi ,
I am having a problem with my awk oneliner , which for some reason leaves the first two records
Input File
$ cat file1
A1:B1:C1:NoLimit
M1:M2:M3:Limit
A2:B2:C2,C3,C4,C5
A3:B3:C3,C4,C5,C6,C7Desired output
A1,B1,C1,NoLimit
M1,M2,M3,Limit
A2,B2,C2
,,,C3
,,,C4
,,,C5
A3,B3,C3... (5 Replies)
Discussion started by: chidori
5 Replies
10. Shell Programming and Scripting
Why the following code printing duplicate records?
bash-4.1$ cat rm1
c1 c2 c3
l1 2 3 4
l2 2 3 2
bash-4.1$ awk '{print $0} OFS = "\n"' rm1
c1 c2 c3
c1 c2 c3
l1 2 3 4
l1 2 3... (4 Replies)
Discussion started by: quincyjones
4 Replies
LEARN ABOUT DEBIAN
bio::asn1::sequence::indexer
Bio::ASN1::Sequence::Indexer(3pm) User Contributed Perl Documentation Bio::ASN1::Sequence::Indexer(3pm)
NAME
Bio::ASN1::Sequence::Indexer - Indexes NCBI Sequence files.
SYNOPSIS
use Bio::ASN1::Sequence::Indexer;
# creating & using the index is just a few lines
my $inx = Bio::ASN1::Sequence::Indexer->new(
-filename => 'seq.idx',
-write_flag => 'WRITE'); # needed for make_index call, but if opening
# existing index file, don't set write flag!
$inx->make_index('seq1.asn', 'seq2.asn');
my $seq = $inx->fetch('AF093062'); # Bio::Seq obj for Sequence (doesn't work yet)
# alternatively, if one prefers just a data structure instead of objects
$seq = $inx->fetch_hash('AF093062'); # a hash produced by Bio::ASN1::Sequence
# that contains all data in the Sequence record
PREREQUISITE
Bio::ASN1::Sequence, Bioperl and all dependencies therein.
INSTALLATION
Same as Bio::ASN1::EntrezGene
DESCRIPTION
Bio::ASN1::Sequence::Indexer is a Perl Indexer for NCBI Sequence genome databases. It processes an ASN.1-formatted Sequence record and
stores the file position for each record in a way compliant with Bioperl standard (in fact its a subclass of Bioperl's index objects).
Note that this module does not parse record, because it needs to run fast and grab only the gene ids. For parsing record, use
Bio::ASN1::Sequence.
As with Bio::ASN1::Sequence, this module is best thought of as beta version - it works, but is not fully tested.
SEE ALSO
Please check out perldoc for Bio::ASN1::EntrezGene for more info.
AUTHOR
Dr. Mingyi Liu <mingyi.liu@gpc-biotech.com>
COPYRIGHT
The Bio::ASN1::EntrezGene module and its related modules and scripts are copyright (c) 2005 Mingyi Liu, GPC Biotech AG and Altana Research
Institute. All rights reserved. I created these modules when working on a collaboration project between these two companies. Therefore a
special thanks for the two companies to allow the release of the code into public domain.
You may use and distribute them under the terms of the Perl itself or GPL (<http://www.gnu.org/copyleft/gpl.html>).
CITATION
Liu, M and Grigoriev, A(2005) "Fast Parsers for Entrez Gene" Bioinformatics. In press
OPERATION SYSTEMS SUPPORTED
Any OS that Perl & Bioperl run on.
METHODS
fetch
Parameters: $geneid - id for the Sequence record to be retrieved
Example: my $hash = $indexer->fetch(10); # get Sequence #10
Function: fetch the data for the given Sequence id.
Returns: A Bio::Seq object produced by Bio::SeqIO::sequence
Notes: Bio::SeqIO::sequence does not exist and probably won't
exist for a while! So call fetch_hash instead
fetch_hash
Parameters: $seqid - id for the Sequence record to be retrieved
Example: my $hash = $indexer->fetch_hash('AF093062');
Function: fetch a hash produced by Bio::ASN1::Sequence for given id
Returns: A data structure containing all data items from the Sequence
record.
Notes: Alternative to fetch()
_file_handle
Title : _file_handle
Usage : $fh = $index->_file_handle( INT )
Function: Returns an open filehandle for the file
index INT. On opening a new filehandle it
caches it in the @{$index->_filehandle} array.
If the requested filehandle is already open,
it simply returns it from the array.
Example : $fist_file_indexed = $index->_file_handle( 0 );
Returns : ref to a filehandle
Args : INT
Notes : This function is copied from Bio::Index::Abstract. Once that module
changes file handle code like I do below to fit perl 5.005_03, this
sub would be removed from this module
perl v5.14.2 2005-05-04 Bio::ASN1::Sequence::Indexer(3pm)