---------- Post updated at 07:20 PM ---------- Previous update was at 07:06 AM ----------
The second code works very well !
Thanks Scrutinizer !
And thanks balajesuri !
I learned a lot in this chat.
---------- Post updated at 08:03 PM ---------- Previous update was at 07:20 PM ----------
I have another question related to this thread (as it is a bit different, I'll post a new thread for this specific question).
Would it be possible as well to number the position of the pattern in the string, in order to add the positions of the first and last characters of the pattern in a new field?
Let' say I have this input.tab file:
and search/extract/replace in the same field, this pattern:
by using Scrutinizer's code:
The output would be:
Hi All,
Greetings!
I have a file of 40000+ lines with different entries, I need matching entries filterd out to their files based on first filed pattern for the matching :
For example:
All server1 entries (in field1) to come together with its path in 2nd field.
The best output I want... (9 Replies)
data:
hello--hello1--hello2--#growncars#vello--hello3--hello4--jello#growncars#dello--gello--gelloA--gelloB#growncars#
I want to be able to print all the values that are found between the patterns "#growncars#" and the next "#growncars#" on the same line.
so the output should be:
... (8 Replies)
Hi all,
I am new to using awk and am quickly discovering what a powerful pattern-recognition tool it is. However, I have what seems like a fairly basic task that I just can't figure out how to perform in one line. I want awk to find and print all the lines in which one of multiple patterns (e.g.... (8 Replies)
Hi experts , im new to Unix,AWK ,and im just not able to get this right.
I need to match for some patterns if it matches I need to print the next few words to it.. I have only three such conditions to match… But I need to print only those words that comes after satisfying the first condition..... (2 Replies)
Hi,
I am trying with the below Perl command to print the first field when the second field matches the given pattern:
perl -lane 'open F, "< myfile"; for $i (<F>) {chomp $i; if ($F =~ /patt$/) {my $f = (split(" ", $i)); print "$f";}} close F' dummy_file
I know I can achieve the same with the... (7 Replies)
First, thanks for the help in previous posts... couldn't have gotten where I am now without it!
So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following:
If $1... (4 Replies)
How can i awk/sed to print the last line of an recurring pattern on the 3rd field?
Input lines:
123456.1 12 1357911 11111.1 01
123456.2 12 1357911 11111.2 02
123456.3 12 1357911 11111.3 03
123456.4 12 1357911 11111.4 04
123456.5 12 1357911 11111.5 05
246810.1 12 1357911 22222.1 01... (4 Replies)
Hi All,
I would like my code to be able to print out the whole line if 1st field has a dot in the number. Sample input and expected output given below.
My AWK code is below but it can;t work, can any expert help me ?
Thanks in advance.
{if ($1 ~ /*\.*/) { print $0 }}
Input:
... (2 Replies)