Match pattern and print the line number of occurence using awk
Hi,
I have a simple problem but i guess stupid enough to figure it out. i have thousands rows of data. and i need to find match patterns of two columns and print the number of rows. for example:
inputfile
There are 5 rows above and i match $1 and $2. Those that match will print out all columns together with the number of rows. I know i can use grep -n to do this, but when i combine grep -n with awk (for matching the two columns) it gives me the sequence no of match pattern which not that i wanted. I want the result like below:-
my codes as follows:-
which gives me this result that i do not want:-
The number in red color is the number for the rows number. I can see this is simple but i just could not get it. pls help. thanks
I have a file nbu_faq.txt (Question/answer) which looks like this
What I am trying to do is write out each question in a file1.txt and than the question/answer in a file2.txt
like this
file1.txt
Q: What is nbu?
Q: What is blablabla...?
Q: Why ....?
file2.txt
Q: What is nbu?
A:... (4 Replies)
Hi,
I have a xml file
<cisco:name>
<cisco:mdNm>Cisco Device 7500 A Series</cisco:mdNm>
<cisco:meNm>10.1.100.19</cisco:meNm>
<cisco:ehNm>/shelf=1</cisco:ehNm>
<cisco:subname>
<cisco:meNm>10.1.100.19</cisco:meNm>
<cisco:sptp>Cisco PortA Series</cisco:sptp>
... (11 Replies)
Hi,
I know how to use awk to search some expressions like five consecutive numbers, , this is easy.
However, how do I make awk print the pattern that is been matched?
For example:
input: usa,canada99292,japan222,france59664,egypt223
output:99292,59664 (6 Replies)
Dear All,
Hv a very specific requirement.
I have a very large text file and in which I have to match a pattern and insert a line above and below.
Eg:
My file
cat test
date1
date2
date3
date4
I need to match 'date3' and insert "Reminder1" above date3 and insert 'reminder2'... (4 Replies)
Data:
Pattern Data Data Data
Data Data Data
Data Data Data
...
With awk, how do I print the pattern matching line, then the subsequent lines following the pattern matching line. Varying number of lines following the pattern matching line. (9 Replies)
I have
2013-06-11 23:55:14 1Umexd-0004cm-IG <= user@domain.com
I need sed/awk operation on this, so that it should print the very next pattern only after the the pattern mach <=
ie only print user@domain.com (7 Replies)
Hi,
Do anybody know how to use awk to count the pattern at specific column?
Input file
M2A928K 419 ath-miR159a,gma-miR159a-3p,ptc-miR159a 60 miR235a
.
.
Output file
M2A928K 419 ath-miR159a,gma-miR159a-3p,ptc-miR159a 60 miR235a 3
.
.
I plan to count how many "miR" in column 3... (2 Replies)
Hello Experts , require help . See below output:
File inputs
------------------------------------------
Server Host = mike
id rl images allocated last updated density
vimages expiration last read <------- STATUS ------->... (4 Replies)
I am trying to combine lines with these conditions:
1. First line starts with text of "libname VALUE db2 datasrc" where VALUE can be any text.
2. If condition1 is met then continue to combine lines through a line that ends with a semicolon.
3. Ignore case when matching patterns and remove any... (5 Replies)
Hi
I need to egrep patterns in a file and limit number of matches to print for each matched pattern.
-m10 option is not working out in my sun solaris 5.10
Please guide me the options to achieve.
if i do head -10 , i wont be getting all pattern match results as output since for a... (10 Replies)
Discussion started by: ananan
10 Replies
LEARN ABOUT OPENSOLARIS
rndc
rndc(1M) System Administration Commands rndc(1M)NAME
rndc - name server control utility
SYNOPSIS
rndc [-V] [-c config-file] [-k key-file] [-s server]
[-p port] [-y key_id] command
DESCRIPTION
The rndc utility controls the operation of a name server. It supersedes the ndc utility that was provided in previous BIND releases. If
rndc is invoked with no command line options or arguments, it prints a short summary of the supported commands and the available options
and their arguments.
The rndc utility communicates with the name server over a TCP connection, sending commands authenticated with digital signatures. The only
supported authentication algorithm in the current versions of rndc and named(1M) is HMAC-MD5, which uses a shared secret on each end of the
connection. This algorithm provides TSIG-style authentication for the command request and the name server's response. All commands sent
over the channel must be signed by a key_id known to the server.
The rndc utility reads a configuration file to determine how to contact the name server and decide what algorithm and key it should use.
OPTIONS
The following options are supported:
-c config-file Use config-file as the configuration file instead of the default /etc/rndc.conf.
-k key-file Use key-file as the key file instead of the default, /etc/rndc.key. The key in /etc/rndc.key is used to authenticate com-
mands sent to the server if the config-file does not exist.
-s server The server argument is the name or address of the server that matches a server statement in the configuration file for
rndc. If no server is supplied on the command line, the host named by the default-server clause in the options statement
of the rndc configuration file is used.
-p port Send commands to TCP port port instead of BIND 9's default control channel port, 953.
-V Enable verbose logging.
-y key_id Use the key key_id from the configuration file. The key_id argument must be known by named with the same algorithm and
secret string for control message validation to succeed. If no key_id is specified, rndc will first look for a key clause
in the server statement of the server being used, or if no server statement is present for that host, then the default-
key clause of the options statement. The configuration file contains shared secrets that are used to send authenticated
control commands to name servers. It should therefore not have general read or write access.
For the complete set of commands supported by rndc, see the BIND 9 Administrator Reference Manual or run rndc without arguments to see its
help message.
LIMITATIONS
The rndc utility does not support all the commands of the BIND 8 ndc utility.
There is no way to provide the shared secret for a key_id without using the configuration file.
Several error messages could be clearer.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWbind |
+-----------------------------+-----------------------------+
|Interface Stability |External |
+-----------------------------+-----------------------------+
SEE ALSO named(1M), rndc-confgen(1M), rndc.conf(4), attributes(5)
BIND 9 Administrator Reference Manual
SunOS 5.11 24 Dec 2008 rndc(1M)