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
CPUPOWER-SET(1) 						  cpupower Manual						   CPUPOWER-SET(1)

NAME
cpupower-set - Set processor power related kernel or hardware configurations SYNOPSIS
cpupower set [ -b VAL ] [ -s VAL ] [ -m VAL ] DESCRIPTION
cpupower set sets kernel configurations or directly accesses hardware registers affecting processor power saving policies. Some options are platform wide, some affect single cores. By default values are applied on all cores. How to modify single core configura- tions is described in the cpupower(1) manpage in the --cpu option section. Whether an option affects the whole system or can be applied to individual cores is described in the Options sections. Use cpupower info to read out current settings and whether they are supported on the system at all. Options --perf-bias, -b Sets a register on supported Intel processore which allows software to convey its policy for the relative importance of performance versus energy savings to the processor. The range of valid numbers is 0-15, where 0 is maximum performance and 15 is maximum energy efficiency. The processor uses this information in model-specific ways when it must select trade-offs between performance and energy efficiency. This policy hint does not supersede Processor Performance states (P-states) or CPU Idle power states (C-states), but allows software to have influence where it would otherwise be unable to express a preference. For example, this setting may tell the hardware how aggressively or conservatively to control frequency in the "turbo range" above the explicitly OS-controlled P-state frequency range. It may also tell the hardware how aggressively it should enter the OS requested C- states. This option can be applied to individual cores only via the --cpu option, cpupower(1). Setting the performance bias value on one CPU can modify the setting on related CPUs as well (for example all CPUs on one socket), because of hardware restrictions. Use cpupower -c all info -b to verify. This options needs the msr kernel driver (CONFIG_X86_MSR) loaded. --sched-mc, -m [ VAL ] --sched-smt, -s [ VAL ] --sched-mc utilizes cores in one processor package/socket first before processes are scheduled to other processor packages/sockets. --sched-smt utilizes thread siblings of one processor core first before processes are scheduled to other cores. The impact on power consumption and performance (positiv or negativ) heavily depends on processor support for deep sleep states, fre- quency scaling and frequency boost modes and their dependencies between other thread siblings and processor cores. Taken over from kernel documentation: Adjust the kernel's multi-core scheduler support. Possible values are: 0 - No power saving load balance (default value) 1 - Fill one thread/core/package first for long running threads 2 - Also bias task wakeups to semi-idle cpu package for power savings SEE ALSO
cpupower-info(1), cpupower-monitor(1), powertop(1) AUTHORS
--perf-bias parts written by Len Brown <len.brown@intel.com> Thomas Renninger <trenn@suse.de> 22/02/2011 CPUPOWER-SET(1)
All times are GMT -4. The time now is 03:04 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy