awk to remove mutiple values from specific pattern, leaving a single value


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting awk to remove mutiple values from specific pattern, leaving a single value
# 8  
Old 05-31-2017
Quote:
Originally Posted by cmccabe
Thank you all very much Smilie

Corona688 in the portion of code below:

Code:
$N=substr($N, 0, RLENGTH+RSTART-1)

is RLENGTH+RSTART-1 the entire string after ANN=, but the index of only the first value? So, basically captures everything but only print index 1. I am just trying to grasp this concept and think the explanation by RavinderSingh13 previously helped. Thank you Smilie.
Hi cmccabe,

It is the combination of both functions match() and substr(), working together that do the work of where to start and what to remove.

match() assigns values to two predefined variables: RSTART which gets the start of the matched portion and RLENGTH which gets the length of the match.

Using those two variables like relative coordinates in the whole string, you can extract that substring portion and keep in a variable using substr()
This User Gave Thanks to Aia For This Post:
# 9  
Old 06-01-2017
Thank you very much Smilie
# 10  
Old 06-02-2017
Hi Gurus... good day;

currently I trying to run the df -g command with awk to get to convert in SQL statement, but I have some errors;

df -g | awk '{print "This is the FileSystem: " $NF, " This is LV: "$1, "This is SIZE: "$2, "This is FREE: " $3, "This is the USED% "$4}'

This on AIX operative system;

But I need replace the words "This is the...", but I dont know how to...กก

Some can help me..

best regards;

Wilmer
# 11  
Old 06-02-2017
Quote:
Originally Posted by wcastibl
Hi Gurus... good day;

currently I trying to run the df -g command with awk to get to convert in SQL statement, but I have some errors;

df -g | awk '{print "This is the FileSystem: " $NF, " This is LV: "$1, "This is SIZE: "$2, "This is FREE: " $3, "This is the USED% "$4}'

This on AIX operative system;

But I need replace the words "This is the...", but I dont know how to...กก

Some can help me..

best regards;

Wilmer
Please don't hijack other folks' threads - open your own.
Thanks
# 12  
Old 06-02-2017
Moderator's Comments:
Mod Comment Posts #10 and #11 are duplicated in other threads and are not related to the topic this thread was created to discuss. Any further discussion on post #10 should be directed to the thread Using df -g command with awk to get SQL statement rather than be posted as a response in this thread.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. 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

4. 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

5. 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

6. 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

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question