Sponsored Content
Top Forums Shell Programming and Scripting awk to print out with two possibilities Post 303000461 by MadeInGermany on Wednesday 12th of July 2017 02:39:15 PM
Old 07-12-2017
This one prints the "Variants Detected:" only once, before the first match. And at the END it prints "nothing detected" if there was not a single match. It uses a control variable wasfound.
Code:
awk -v p1="PASS" -v p2="'oncomineGeneClass'" -v p3="'oncomineVariantClass':" '
  !/^#/ && $0 ~ p1 && $0 ~ p2 && $0 ~ p3 {
    if (!wasfound) {
      print "Variants Detected:"
      wasfound=1
    }
    print
  }
  END {
    if (!wasfound) { print "nothing detected" }
  }
' file

This User Gave Thanks to MadeInGermany For This Post:
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

What can you do with unix what are the possibilities

Where do i get unix at (1 Reply)
Discussion started by: shinobikil
1 Replies

2. Shell Programming and Scripting

How do I get awk to print a " in it's print part?

The line is simple, use " '{ print $1"]"$2"\"$3THE " NEEDS TO GO HERE$4 }' I've tried \", "\, ^" and '"" but none of it works. What am I missing? Putting in the [ between $1 and $2 works fine, I just need to do the same with a ". Thanks. (2 Replies)
Discussion started by: LordJezo
2 Replies

3. Shell Programming and Scripting

Awk problem: How to express the single quote(') by using awk print function

Actually I got a list of file end with *.txt I want to use the same command apply to all the *.txt Thus I try to find out the fastest way to write those same command in a script and then want to let them run automatics. For example: I got the file below: file1.txt file2.txt file3.txt... (4 Replies)
Discussion started by: patrick87
4 Replies

4. Shell Programming and Scripting

Find command possibilities

Using find command is the below possible ? find /home/abcd/****/efgh where the "****" can be any name/character. Thanks, Vasanth. (2 Replies)
Discussion started by: skcvasanth
2 Replies

5. Ubuntu

Restricted access possibilities

Hi, I have given a laptop from company with Ubuntu 10.04 on it. I have restricted access over it, means I have been given sudo login on it. SO I am unable to so many major activities over it, Can you all people tell me the Terminal tricks that I can use to get my hands on it. (1 Reply)
Discussion started by: nixhead
1 Replies

6. Shell Programming and Scripting

configure bash completion for multiple possibilities

Hello, Bash completion is great, but there are some features I'd like to change. One thing is the behaviour when there are lots of very similar possibilities. E.g., my directory contains 133 files, from pubmed_result1.txt to pubmed_result133.txt $ ls Lyonprim/p Display all 133... (2 Replies)
Discussion started by: jossojjos
2 Replies

7. Shell Programming and Scripting

Awk: Print count for column in a file using awk

Hi, I have the following input in a file & need output as mentioned below(need counter of every occurance of field which is to be increased by 1). Input: 919143110065 919143110065 919143110052 918648846132 919143110012 918648873782 919143110152 919143110152 919143110152... (2 Replies)
Discussion started by: siramitsharma
2 Replies

8. Shell Programming and Scripting

Script to find the available number possibilities

Hi, I try to get the combination of 6 numbers from (1-60) using any script. Any script that can help me to fix this ... EG: The output should be like that different possibilities from 1-60... 1) 1 3 15 29 30 42 2) 4 5 6 31 44 60 like the above ... Hereas, I need all the possibilities... (5 Replies)
Discussion started by: gsiva
5 Replies
PadWalker(3)						User Contributed Perl Documentation					      PadWalker(3)

NAME
PadWalker - play with other peoples' lexical variables SYNOPSIS
use PadWalker qw(peek_my peek_our peek_sub closed_over); ... DESCRIPTION
PadWalker is a module which allows you to inspect (and even change!) lexical variables in any subroutine which called you. It will only show those variables which are in scope at the point of the call. PadWalker is particularly useful for debugging. It's even used by Perl's built-in debugger. (It can also be used for evil, of course.) I wouldn't recommend using PadWalker directly in production code, but it's your call. Some of the modules that use PadWalker internally are certainly safe for and useful in production. peek_my LEVEL peek_our LEVEL The LEVEL argument is interpreted just like the argument to "caller". So peek_my(0) returns a reference to a hash of all the "my" variables that are currently in scope; peek_my(1) returns a reference to a hash of all the "my" variables that are in scope at the point where the current sub was called, and so on. "peek_our" works in the same way, except that it lists the "our" variables rather than the "my" variables. The hash associates each variable name with a reference to its value. The variable names include the sigil, so the variable $x is represented by the string '$x'. For example: my $x = 12; my $h = peek_my (0); ${$h->{'$x'}}++; print $x; # prints 13 Or a more complex example: sub increment_my_x { my $h = peek_my (1); ${$h->{'$x'}}++; } my $x=5; increment_my_x; print $x; # prints 6 peek_sub SUB The "peek_sub" routine takes a coderef as its argument, and returns a hash of the "my" variables used in that sub. The values will usually be undefined unless the sub is in use (i.e. in the call-chain) at the time. On the other hand: my $x = "Hello!"; my $r = peek_sub(sub {$x})->{'$x'}; print "$$r "; # prints 'Hello!' If the sub defines several "my" variables with the same name, you'll get the last one. I don't know of any use for "peek_sub" that isn't broken as a result of this, and it will probably be deprecated in a future version in favour of some alternative interface. closed_over SUB "closed_over" is similar to "peek_sub", except that it only lists the "my" variables which are used in the subroutine but defined outside: in other words, the variables which it closes over. This does have reasonable uses: see Data::Dump::Streamer, for example (a future version of which may in fact use "closed_over"). set_closed_over SUB, HASH_REF "set_closed_over" reassigns the pad variables that are closed over by the subroutine. The second argument is a hash of references, much like the one returned from "closed_over". var_name LEVEL, VAR_REF var_name SUB, VAR_REF "var_name(sub, var_ref)" returns the name of the variable referred to by "var_ref", provided it is a "my" variable used in the sub. The "sub" parameter can be either a CODE reference or a number. If it's a number, it's treated the same way as the argument to "peek_my". For example, my $foo; print var_name(0, $foo); # prints '$foo' sub my_name { return var_name(1, shift); } print my_name($foo); # ditto AUTHOR
Robin Houston <robin@cpan.org> With contributions from Richard Soberberg, Jesse Luehrs and Yuval Kogman, bug-spotting from Peter Scott, Dave Mitchell and Goro Fuji, and suggestions from demerphq. SEE ALSO
Devel::LexAlias, Devel::Caller, Sub::Parameters COPYRIGHT
Copyright (c) 2000-2009, Robin Houston. All Rights Reserved. This module is free software. It may be used, redistributed and/or modified under the same terms as Perl itself. perl v5.16.2 2012-08-24 PadWalker(3)
All times are GMT -4. The time now is 04:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy