01-17-2014
Hi ,
Thanks all for your reply ..
I have the similar query but for my case I want add another line before that matched line (ie, Realized what you gotta do).
thanks in advance
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi All,
I have an input below. If the term in the 1st column is equal, print the last row which 1st column is equal.In the below example, it's " 0001 k= 27 " and " 0004 k= 6 " (depicted in bold). Those terms in 1st column which are not repetitive are to be printed as well. Can any body help me... (9 Replies)
Discussion started by: Raynon
9 Replies
2. Shell Programming and Scripting
Hi all,
I have a lot of files with extension ".o" and I would like to extract the 10th line after (last) occurrence of a given string in each of the files.
I tried:
$ grep "string_to_look_for" *.o -A 10 | tail -1
but it gives the occurrence in the last file with extension .o
... (1 Reply)
Discussion started by: f_o_555
1 Replies
3. Shell Programming and Scripting
Lets say I have file.txt:
(Product:Price:QuantityAvailable) (: as delimiter)
Chocolate:5:5
Banana:33:3
I am doing a edit/update function.
I want to change the Quantity Available, so I tried using the SED command to replace 5, but my Price which is also 5 is changed instead.
(for the Banana... (13 Replies)
Discussion started by: andylbh
13 Replies
4. Shell Programming and Scripting
Guys,
I am trying the following:
i have a log file of a webbap which logs in the following pattern:
2011-08-14 21:10:04,535 blablabla ERROR blablabla
bla
bla
bla
bla
2011-08-14 21:10:04,535 blablabla ERROR blablabla
bla
bla
bla
... (6 Replies)
Discussion started by: ppolianidis
6 Replies
5. Shell Programming and Scripting
Hi, i have file f1.txt with data like:
CHECK
a
b
CHECK
c
d
CHECK
e
f
JOB_START
....
I want to match the last occurrence of 'CHECK' until the end of the file.
I can use awk:
awk '/^CHECK/ { buf = "" } { buf = buf "\n" $0 } END { print buf }' f1.txt | tail +2Is there a cleaner way of... (2 Replies)
Discussion started by: ysrini
2 Replies
6. UNIX for Dummies Questions & Answers
Hi,
let's say an input looks like:
A|C|C|D
A|C|I|E
A|B|I|C
A|T|I|B
as the title of the thread explains, I am trying to get something like:
1|A=4
2|C=2|B=1|T=1
3|I=3|C=1
4|D=1|E=1|C=1|B=1
i.e. a count of every character in each field (first column of output) independently, sorted... (4 Replies)
Discussion started by: beca123456
4 Replies
7. Shell Programming and Scripting
I apologize if it was asked before but I couldn't find something related.
I want to replace 2 strings in a file
e.g
pwddb=Lar1wod (need to replace string after =)
pwdapp=Wde2xe (need to replace string after =)
AND in same file want to find last occurrence of a string (SR2-134561),... (2 Replies)
Discussion started by: J_ang
2 Replies
8. Shell Programming and Scripting
echo 'String#1 and String#2' | egrep -o -m 1 'String#.{1}'
String#1
String#2
I'm trying to just match the first occurrence of 'String#' + 1 character. I thought the "-m 1" switch would do that for me. Instead I get both occurrences. Can somebody provide some insight?
Thanks! (5 Replies)
Discussion started by: sudo
5 Replies
9. UNIX for Dummies Questions & Answers
Hi all,
I have an input file as below. I would like to count the occurrence of pattern matching 8th field for each line.
Input:
field_01 field_02 field_03 field_04 field_05 field_06 field_07 field_08
TA T TA T TA TA TA... (3 Replies)
Discussion started by: huiyee1
3 Replies
10. Shell Programming and Scripting
Hi, i have file file.txt with data like:
START
03:11:30 a
03:11:40 b
END
START
03:13:30 eee
03:13:35 fff
END
jjjjjjjjjjjjjjjjjjjjj
START
03:14:30 eee
03:15:30 fff
END
ggggggggggg
iiiiiiiiiiiiiiiiiiiiiiiii
I want the below output
START (13 Replies)
Discussion started by: Jyotshna
13 Replies
LEARN ABOUT DEBIAN
ldns-testns
ldns-testns(1) General Commands Manual ldns-testns(1)
NAME
ldns-testns - simple fake nameserver tool
SYNOPSYS
ldns-testns [ OPTION ] datafile
DESCRIPTION
ldns-testns can be used to provide answers to DNS queries for testing. The answers are premade, and can be tailored to testing needs. The
answers can be wildly invalid or unparseable.
This program is a debugging aid. It is not efficient, especially with a long config file, but it can give any reply to any query. This can
help the developer pre-script replies for queries.
It listens to IP4 UDP and TCP by default. You can specify a packet RR by RR with header flags to return.
ldns-testns is not meant for production use.
OPTIONS
-r Listens to a random port. The port number is printed to stdout.
-p port
Listens to the specified port.
-f num Forks this number of additional instances that serve the same ports and same datafile. They do not exit; printed is 'forked pid:
<num>' and you have to kill them yourself.
-v Outputs more debug information. It is possible to give this option multiple times to increase verbosity level.
-6 Bind to IP6 address instead of IP4. Use together with -p.
datafile
The data file is read on start up. It contains queries and the packets that should be sent in answer to those queries. The data file
format is explained below.
DATA FILE FORMAT
The data file format has ';' to denote comment. A number of entries are processed first to last. The first matching entry is used to answer
the query with. This is a line based format. DNS resource records are entered in zone-file format.
You can use $ORIGIN and $TTL directives. Zone file '(' and ')' to span multiple lines are not allowed.
$ORIGIN origin $TTL default_ttl
ENTRY_BEGIN
; first give MATCH lines, that say what queries are matched ; by this entry. ; 'opcode' makes the query match the opcode from the reply ;
if you leave it out, any opcode matches this entry. ; 'qtype' makes the query match the qtype from the reply ; 'qname' makes the query
match the qname from the reply ; 'serial=1023' makes the query match if ixfr serial is 1023.
MATCH [opcode] [qtype] [qname] [serial=<value>] MATCH [UDP|TCP] MATCH ...
; Then the REPLY header is specified.
REPLY opcode, rcode or flags.
(opcode) QUERY IQUERY STATUS NOTIFY UPDATE
(rcode) NOERROR FORMERR SERVFAIL NXDOMAIN NOTIMPL YXDOMAIN
YXRRSET NXRRSET NOTAUTH NOTZONE
(flags) QR AA TC RD CD RA AD
REPLY ...
; any additional actions to do.
ADJUST copy_id ; 'copy_id' copies the ID from the query to the answer.
; 'sleep=10' sleeps for 10 seconds before giving the answer (TCP is open)
ADJUST [sleep=<num>] ; sleep before giving any reply ADJUST [packet_sleep=<num>] ; sleep before this packet in sequence
SECTION QUESTION <RRs, one per line> ; the RRcount is determined automatically.
SECTION ANSWER <RRs, one per line>
SECTION AUTHORITY <RRs, one per line>
SECTION ADDITIONAL <RRs, one per line>
EXTRA_PACKET ; follow with SECTION, REPLY for more packets. HEX_ANSWER_BEGIN ; follow with hex data
; this replaces any answer packet constructed
; with the SECTION keywords (only SECTION QUERY
; is used to match queries). If the data cannot
; be parsed, ADJUST rules for the answer packet
; are ignored
HEX_ANSWER_END
ENTRY_END
AUTHOR
Written by the ldns team as an example for ldns usage, and for testing purposes.
REPORTING BUGS
Report bugs to <ldns-team@nlnetlabs.nl>.
COPYRIGHT
Copyright (C) 2006-2008 NLnet Labs. This is free software. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE.
14 Dec 2006 ldns-testns(1)