Sponsored Content
Top Forums Shell Programming and Scripting Printing next two lines from a file after grepping a specific pattern Post 302833851 by Priya Amaresh on Thursday 18th of July 2013 02:36:41 AM
Old 07-18-2013
Code:
# vi require.txt 
1,BANK,Read blocks that cycle.
 yellow 
Read blocks.
 2,ACCOUNT,Finished 
Red 
Finished . 
3,LOAN, pipe 
white 
pipe 
4,PROFIT,Resolve. 
black 
Resolve
5,PROFITIABLE,Loss
orange
Loss
6,ACCOUNTANT,clerk
yellow
work

If i use the code
awk 'c-->0;$0~s{if(b)for(c=b+1;c>1;c--)print r[(NR-c+1)%b];print;c=a}b{r[NR%b]=$0}' b=0 a=2 s="ACCOUNT" require.txt

The output is
2,ACCOUNT,Finished
Red
Finished .
6,ACCOUNTANT,clerk
yellow
work


This grep all pattern relative to ACCOUNT like ACCOUNT and ACCOUNTANT are grepped..

Please suggest me a way to grep the exact pattern ACCOUNT alone from this file
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Printing lines with specific awk NF

I have this files: ./frm/lf_mt1_cd.Ic_cell_template.attr ./die/addgen_tb_pumd.Ic_cell_template.attr ./min_m1_n.Ic_cell_template.attr When I use: awk -F\/ '{print NF}' Would result to: 3 3 2 I would like to list the files with 3 fields on it. Any Suggestions? (1 Reply)
Discussion started by: jehrome_rando
1 Replies

2. Shell Programming and Scripting

how to delete lines from a file which starts with a specific pattern

I need to delete those lines from a file, which starts with 45. How to do it? (3 Replies)
Discussion started by: mady135
3 Replies

3. Shell Programming and Scripting

merging of 2 consecutive lines in a file for a specific pattern

Hi , I'm looking for a way to merge two lines only for a given pattern / condition. Input : abcd/dad + -49.201 2.09 -49.5 34 ewrew rewtre * fdsgfds/dsgf/sdfdsfasdd + -4.30 0.62 -49.5 45 sdfdsf cvbbv * sdfds/retret/asdsaddsa + ... (1 Reply)
Discussion started by: novice_man
1 Replies

4. Shell Programming and Scripting

Printing several lines of a file after a specific expression

Hello, I want to print a number of lines of a file after a specific expression of a line. I have this sed command but it prints only 1 line after the expression. How could I adapt it to print for instance 10 lines after or 15 lines after ? sed -n '/regexp/{n;p;}' Thx & Regs, Rany. (5 Replies)
Discussion started by: rany1
5 Replies

5. Shell Programming and Scripting

Printing all lines before a specific string and a custom message 2 lines after

Hello all, I need to print all the lines before a specific string and print a custom message 2 lines after that. So far I have managed to print everything up the string, inclusively, but I can't figure out how to print the 2 lines after that and the custom message. My code thus far is:... (4 Replies)
Discussion started by: SEinT
4 Replies

6. UNIX for Advanced & Expert Users

Need command for grepping pattern lines with subsequent lines

Hi, I have a requirement like, I have a list of pattens in a file say pattern.txt, PHC111 PHC113 and in another file called master.lst i have entries like, PHC111 a b PHC112 a PHC113 b c PHC114 d e (5 Replies)
Discussion started by: rbalaj16
5 Replies

7. Shell Programming and Scripting

Grepping a specific row from a file

Hi I have output of a command saved in a file.. # cat /file.txt System: cu=4 ent=0.1 mode=on cu min u s w i 0 500 0.1 0.3 0.5 0.1 1 200 0.5 0.2 0.3 0.0 By using ksh, what I need to do is, I need to grep the u,s,w and i... (5 Replies)
Discussion started by: Priya Amaresh
5 Replies

8. UNIX for Dummies Questions & Answers

Printing lines with specific strings at specific columns

Hi I have a file which is tab-delimited. Now, I'd like to print the lines which have "chr6" string in both first and second columns. Could anybody help? (3 Replies)
Discussion started by: a_bahreini
3 Replies

9. Shell Programming and Scripting

Sed: printing lines AFTER pattern matching EXCLUDING the line containing the pattern

'Hi I'm using the following code to extract the lines(and redirect them to a txt file) after the pattern match. But the output is inclusive of the line with pattern match. Which option is to be used to exclude the line containing the pattern? sed -n '/Conn.*User/,$p' > consumers.txt (11 Replies)
Discussion started by: essem
11 Replies

10. Shell Programming and Scripting

Match all lines in file where specific text pattern is less than

In the below file I am trying to grep or similar, all lines where only AF= is less than 0.4.. Thank you :). grep grep "AF=" ,+ .4 file file 12 112036782 . T C 34.0248 PASS ... (3 Replies)
Discussion started by: cmccabe
3 Replies
define cached server(1m)												  define cached server(1m)

NAME
define cached server - Creates knowledge of a server in the local clerk's cache SYNOPSIS
cdscp define cached server name tower value ARGUMENTS
A simple name for the cached server. The protocol sequence and network address of the server node. The format is protocol-sequence:net- work-address. A protocol-sequence is a character string identifying the network protocols used to establish a relationship between a client and server. There are two choices of protocol sequence, depending on the network address that is supplied in the binding: ncacn_ip_tcp or ncadg_ip_udp. For the network-address, specify an Internet address using the common Internet address notation. For more information about this format, see the RPC introduction in the DCE Application Development Reference. DESCRIPTION
The define cached server command creates knowledge of a server in the local clerk's cache. This command is typically used to manually pro- vide configuration information to a clerk that cannot automatically configure itself. This is required, for instance, to give the clerk addressing information about a server across a WAN. Once the clerk knows about one server, it can find other servers through referrals. Privilege Required You must have write permission to the clerk. NOTE
This command is replaced at Revision 1.1 by the dcecp command and may not be provided in future releases of DCE. EXAMPLES
The following command creates knowledge of the server nrl in the local clerk's cache: cdscp> define cached server nrl tower ncacn_ip_tcp:16.20.15.25 RELATED INFORMATION
Commands: clear cached server(1m), dump clerk cache(1m), show cached server(1m) Books: OSF DCE Application Development Reference define cached server(1m)
All times are GMT -4. The time now is 09:24 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy