Sponsored Content
Top Forums Shell Programming and Scripting awk to remove mutiple values from specific pattern, leaving a single value Post 302998344 by RavinderSingh13 on Tuesday 30th of May 2017 03:19:17 PM
Old 05-30-2017
Hello cmccabe,

Not sure if I got this 100%, could you please try following and let me know if this helps you.
Code:
awk '!/ANN.*[;,]/{print;next} {match($0,/ANN[^:]*/);VAL=substr($0,RSTART,RLENGTH);if(VAL){split(VAL, A," ");sub(/[;,].*/,"",A[1]);sub(/ANN[^:]*/,A[1] "\t" A[2],$0)}} 1'  Input_file

Adding a non-one liner form of solution too now.
Code:
awk '!/ANN.*[;,]/{
                        print;
                        next
                 }
                 {
                        match($0,/ANN[^:]*/);
                        VAL=substr($0,RSTART,RLENGTH);
                        if(VAL){
                                split(VAL, A," ");
                                sub(/[;,].*/,"",A[1]);
                                sub(/ANN[^:]*/,A[1] "\t" A[2],$0)
                                }
                 }
      1
    '    Input_file

Thanks,
R. Singh
This User Gave Thanks to RavinderSingh13 For This Post:
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Remove specific pattern header and its content problem facing

Input file: >TRACK: Position: 1 TYPE: 1 Pos: SVAVPQRHHPGGTVFREPIIIPAIPRLVPGWNKPIIIGRHAFGDQYRATDRVIPGPGKLE LVYTPVNGEPETVKVYDFQGGGIAQTQYNTDESIRGFAHASFQMALLKGLPLYMSTKNTI LKRYDGRFKDIFQEIYESTYQKDFEAKNLWYEHRLIDDMVAQMIKSEGGFVMALKNYDGD >TRACK: Position: 1 TYPE: 2 Pos: FAHASFQMALLKGLPLYMS... (8 Replies)
Discussion started by: patrick87
8 Replies

2. Shell Programming and Scripting

NAWK to remove lines that matches a specific pattern

Hi, I have requirement that I need to split my input file into two files based on a search pattern "abc" For eg. my input file has below content abc defgh zyx I need file 1 with abc and file2 with defgh zyx I can use grep command to acheive this. But with grep I need... (8 Replies)
Discussion started by: sbhuvana20
8 Replies

3. Shell Programming and Scripting

Help with remove last text of a file that have specific pattern

Input file matrix-remodelling_associated_8_ aurora_interacting_1_ L20 von_factor_A_domain_1 ATP_containing_3B_ . . Output file matrix-remodelling_associated_8 aurora_interacting_1 L20 von_factor_A_domain_1 ATP_containing_3B . . (3 Replies)
Discussion started by: perl_beginner
3 Replies

4. Shell Programming and Scripting

How to remove content present in between specific pattern ?

Hi, I have a file with following pattern. We are looking to filter out only specific content from this file. sample BLAdmins Server.* LinuxAdmins Server.* Policy Name: Recommended Default ACL Policy Everyone ACLPushJob.Read Everyone ACLTemplate.Read Everyone ... (9 Replies)
Discussion started by: Litu19
9 Replies

5. Shell Programming and Scripting

Fetch the values based on a Key using awk from single file

Hi, Please help to fetch the values for a key from below data format in linux. Sample Input Data Format 11055005|PurchaseCondition|GiftQuantity|1 11055005|PurchaseCondition|MinimumPurchase|400 11055005|GiftCatalogEntryIdentifier|Id|207328014 11429510|PurchaseCondition|GiftQuantity|1... (2 Replies)
Discussion started by: mohanalakshmi
2 Replies

6. Shell Programming and Scripting

Convert mutiple spaces file to single tab

I have the following file I wanted to convert mutiple spaces to tab: I tried cat filename | tr ' ' '\t' or sed 's/ */ /' FILE but it looses the format 5557263102 5557263102 5552074858 5726310211 5557263102 5557263102 5557263103 5557263103 2142406768 ... (2 Replies)
Discussion started by: amir07
2 Replies

7. Shell Programming and Scripting

Find specific pattern and change some of block values using awk

Hi, Could you please help me finding a way to replace a specific value in a text block when matching a key pattern ? I got the keys and the values from a command similar to: echo -e "key01 Nvalue01-1 Nvalue01-2 Nvalue01-3\nkey02 Nvalue02-1 Nvalue02-2 Nvalue02-3 \nkey03 Nvalue03-1... (2 Replies)
Discussion started by: alex2005
2 Replies

8. Shell Programming and Scripting

Writing single script with mutiple sbatch parts

Hello, I wrote several scripts that work with job arrays (sbatch) that look like this: #!/bin/bash #SBATCH --partition=carl.p #SBATCH --ntasks=4 #SBATCH --time=0-10:00 #SBATCH --mem-per-cpu=48G #SBATCH --job-name=basic_test #SBATCH --mail-type=END,FAIL #SBATCH --mail-user= #SBATCH... (2 Replies)
Discussion started by: idbemad
2 Replies

9. UNIX for Beginners Questions & Answers

awk to remove pattern and lines above pattern

In the awk below I am trying to remove all lines above and including the pattern Test or Test2. Each block is seperated by a newline and Test2 also appears in the lines to keep but it will always have additional text after it. The Test to remove will not. The awk executed until the || was added... (2 Replies)
Discussion started by: cmccabe
2 Replies

10. UNIX for Beginners Questions & Answers

awk with sed to combine lines and remove specific odd # pattern from line

In the awk piped to sed below I am trying to format file by removing the odd xxxx_digits and whitespace after, then move the even xxxx_digit to the line above it and add a space between them. There may be multiple lines in file but they are in the same format. The Filename_ID line is the last line... (4 Replies)
Discussion started by: cmccabe
4 Replies
MAKEINFO(1)							   User Commands						       MAKEINFO(1)

NAME
makeinfo - translate Texinfo documents SYNOPSIS
makeinfo [OPTION]... TEXINFO-FILE... DESCRIPTION
Translate Texinfo source documentation to various other formats, by default Info files suitable for reading online with Emacs or standalone GNU Info. General options: --error-limit=NUM quit after NUM errors (default 100). --force preserve output even if errors. --help display this help and exit. --no-validate suppress node cross-reference validation. --no-warn suppress warnings (but not errors). --reference-limit=NUM warn about at most NUM references (default 1000). -v, --verbose explain what is being done. --version display version information and exit. Output format selection (default is to produce Info): --docbook output Docbook XML rather than Info. --html output HTML rather than Info. --xml output Texinfo XML rather than Info. --plaintext output plain text rather than Info. General output options: -E, --macro-expand FILE output macro-expanded source to FILE. ignoring any @setfilename. --no-headers suppress node separators, Node: lines, and menus from Info output (thus producing plain text) or from HTML (thus producing shorter output); also, write to standard output by default. --no-split suppress splitting of Info or HTML output, generate only one output file. --number-sections output chapter and sectioning numbers. -o, --output=FILE output to FILE (directory if split HTML), Options for Info and plain text: --enable-encoding output accented and special characters in Info output based on @documentencoding. --fill-column=NUM break Info lines at NUM characters (default 72). --footnote-style=STYLE output footnotes in Info according to STYLE: `separate' to put them in their own node; `end' to put them at the end of the node in which they are defined (default). --paragraph-indent=VAL indent Info paragraphs by VAL spaces (default 3). If VAL is `none', do not indent; if VAL is `asis', preserve existing indentation. --split-size=NUM split Info files at size NUM (default 300000). Options for HTML: --css-include=FILE include FILE in HTML <style> output; read stdin if FILE is -. Options for XML and Docbook: --output-indent=VAL indent XML elements by VAL spaces (default 2). If VAL is 0, ignorable whitespace is dropped. Input file options: --commands-in-node-names allow @ commands in node names. -D VAR define the variable VAR, as with @set. -I DIR append DIR to the @include search path. -P DIR prepend DIR to the @include search path. -U VAR undefine the variable VAR, as with @clear. Conditional processing in input: --ifdocbook process @ifdocbook and @docbook even if not generating Docbook. --ifhtml process @ifhtml and @html even if not generating HTML. --ifinfo process @ifinfo even if not generating Info. --ifplaintext process @ifplaintext even if not generating plain text. --iftex process @iftex and @tex; implies --no-split. --ifxml process @ifxml and @xml. --no-ifdocbook do not process @ifdocbook and @docbook text. --no-ifhtml do not process @ifhtml and @html text. --no-ifinfo do not process @ifinfo text. --no-ifplaintext do not process @ifplaintext text. --no-iftex do not process @iftex and @tex text. --no-ifxml do not process @ifxml and @xml text. Also, for the --no-ifFORMAT options, do process @ifnotFORMAT text. The defaults for the @if... conditionals depend on the output format: if generating HTML, --ifhtml is on and the others are off; if generating Info, --ifinfo is on and the others are off; if generating plain text, --ifplaintext is on and the others are off; if generating XML, --ifxml is on and the others are off. EXAMPLES
makeinfo foo.texi write Info to foo's @setfilename makeinfo --html foo.texi write HTML to @setfilename makeinfo --xml foo.texi write Texinfo XML to @setfilename makeinfo --docbook foo.texi write DocBook XML to @setfilename makeinfo --no-headers foo.texi write plain text to standard output makeinfo --html --no-headers foo.texi write html without node lines, menus makeinfo --number-sections foo.texi write Info with numbered sections makeinfo --no-split foo.texi write one Info file however big REPORTING BUGS
Email bug reports to bug-texinfo@gnu.org, general questions and discussion to help-texinfo@gnu.org. Texinfo home page: http://www.gnu.org/software/texinfo/ COPYRIGHT
Copyright (C) 2004 Free Software Foundation, Inc. There is NO warranty. You may redistribute this software under the terms of the GNU General Public License. For more information about these matters, see the files named COPYING. SEE ALSO
The full documentation for makeinfo is maintained as a Texinfo manual. If the info and makeinfo programs are properly installed at your site, the command info makeinfo should give you access to the complete manual. makeinfo 4.8 December 2004 MAKEINFO(1)
All times are GMT -4. The time now is 02:30 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy