Sponsored Content
Top Forums Shell Programming and Scripting Greping in between two different lines. Post 302382027 by jwillis0720 on Monday 21st of December 2009 10:29:07 PM
Old 12-21-2009
Greping in between two different lines.

I know you could use the grep "something" -A200 flag to get all the lines past your pattern. Is there a way to get all the lines in between two patterns? The -a flag will not work since all lines in between the two patterns don't have a constant number.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with greping a field

Hi, Suppose I have a file as below and I just want the field Invoice Number from this file , How can I do it. /home/arbor>cat PH0034090202314800030IM-001 0Yp825XMilperra NSW 1891 189110H14V1Sp2871Yp300X Customer Service : 0000-368-81118H6.5V0Sp3130Yp50X ... (7 Replies)
Discussion started by: rooh
7 Replies

2. UNIX for Dummies Questions & Answers

GREPing for Nulls

I just had a filesystem / file corruption issue on my HSP's server due to disk capacity limits and fileswapping. I discovered that certain files got corrupted when fileswapping was not successful and they ended up with a string of control characters, or what I believe to be nulls, in them. Does... (4 Replies)
Discussion started by: Dr. DOT
4 Replies

3. Shell Programming and Scripting

Greping certain lines

One of my outout is like this as shown below. How can I grep only the lines after the line "Affected files ...". No of lines after the line "Affected files ..." may vary. $ cat file_A Change 149133 by csaha@test_depo_csaha on 2006/02/08 01:40:57 *pending* This is to test change #... (5 Replies)
Discussion started by: csaha
5 Replies

4. Shell Programming and Scripting

need help in greping

i have a ksh script : #!/bin/ksh TZ=`date +%Z`+24 ;a=`date +%Y-%m-%d` b=`date +"%H:%M:%S"` cd /ednadtu3/u01/pipe/logs for i in Archiver1.log do cat $i | grep $a | grep $b >> /ednadtu3/u01/pipe/naveed/Insert_Date.txt done... (4 Replies)
Discussion started by: ali560045
4 Replies

5. Shell Programming and Scripting

Greping the required parameter...

Hi Friends, Urgently required to know this : I have a file which has several stanzas like below : CuDv: name = "hdisk3" status = 1 chgstatus = 2 ddins = "scdisk" location = "03-08-01-11,0" parent = "scsi1" connwhere =... (3 Replies)
Discussion started by: vijaya2006
3 Replies

6. Shell Programming and Scripting

greping ip address

I have this line BTSRTRGRP-448-1-1 10.162.141.118/255.255.255.254 - I need to print only the IPADDRESS and not the subnet mask. If i use cut -c30-43 I get the ipaddress, where as in some cases if the last octet is of single digit (10.162.141.8/255.255.255.254) it... (2 Replies)
Discussion started by: miltonrods
2 Replies

7. Shell Programming and Scripting

need help in greping

Hi, i have to find a string in a file and positin of the string in the file would come in some particular interval. let's say file is 1-1000 lines and string is in from 200-300line. could any one suggest me how to get make the grep search for the string in that particular portion of the... (4 Replies)
Discussion started by: tarakant
4 Replies

8. Shell Programming and Scripting

greping $2 into a list

Hi When I run this command: lsuser -a auditclasses ALL I got: user1 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user2 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user3 auditclasses=general,objects,cron,files,rbac,audit,lvm,aixpert user4... (7 Replies)
Discussion started by: iga3725
7 Replies

9. Shell Programming and Scripting

Having trouble greping a variable

I'm trying to take a users input, and then such a text file to see if it contains it. I get an error when running it: "./Login.sh: Line 8: echo Username read username if ; then echo Login successful. else echo Failed to login. fi If someone could give me some input to where I'm... (4 Replies)
Discussion started by: Hegarz
4 Replies

10. Shell Programming and Scripting

awk and greping between lines

i want to grab lines from a file that are between two patterns (including the lines that contain the pattern). here's what im currently doing: data.txt aaa bbb cccc ddd eee ffff ddd code: awk '/bbb/,/fff/ && $0 !~ /ddd/' cdsnmp.sh I want to grab lines between and including bbb... (5 Replies)
Discussion started by: SkySmart
5 Replies
fgrep(1)							   User Commands							  fgrep(1)

NAME
fgrep - search a file for a fixed-character string SYNOPSIS
/usr/bin/fgrep [-bchilnsvx] -e pattern_list [file...] /usr/bin/fgrep [-bchilnsvx] -f file [file...] /usr/bin/fgrep [-bchilnsvx] pattern [file...] /usr/xpg4/bin/fgrep [-bchilnqsvx] -e pattern_list [-f file] [file...] /usr/xpg4/bin/fgrep [-bchilnqsvx] [-e pattern_list] -f file [file...] /usr/xpg4/bin/fgrep [-bchilnqsvx] pattern [file...] DESCRIPTION
The fgrep (fast grep) utility searches files for a character string and prints all lines that contain that string. fgrep is different from grep(1) and from egrep(1) because it searches for a string, instead of searching for a pattern that matches an expression. fgrep uses a fast and compact algorithm. The characters $, *, [, ^, |, (, ), and are interpreted literally by fgrep, that is, fgrep does not recognize full regular expressions as does egrep. These characters have special meaning to the shell. Therefore, to be safe, enclose the entire string within single quotes (a'). If no files are specified, fgrep assumes standard input. Normally, each line that is found is copied to the standard output. The file name is printed before each line that is found if there is more than one input file. OPTIONS
The following options are supported for both /usr/bin/fgrep and /usr/xpg4/bin/fgrep: -b Precedes each line by the block number on which the line was found. This can be useful in locating block numbers by con- text. The first block is 0. -c Prints only a count of the lines that contain the pattern. -e pattern_list Searches for a string in pattern-list. This is useful when the string begins with a -. -f pattern-file Takes the list of patterns from pattern-file. -h Suppresses printing of files when searching multiple files. -i Ignores upper/lower case distinction during comparisons. -l Prints the names of files with matching lines once, separated by new-lines. Does not repeat the names of files when the pattern is found more than once. -n Precedes each line by its line number in the file. The first line is 1. -s Works silently, that is, displays nothing except error messages. This is useful for checking the error status. -v Prints all lines except those that contain the pattern. -x Prints only lines that are matched entirely. /usr/xpg4/bin/fgrep The following options are supported for /usr/xpg4/bin/fgrep only: -q Quiet. Does not write anything to the standard output, regardless of matching lines. Exits with zero status if an input line is selected. OPERANDS
The following operands are supported: file Specifies a path name of a file to be searched for the patterns. If no file operands are specified, the standard input will be used. /usr/bin/fgrep pattern Specifies a pattern to be used during the search for input. /usr/xpg4/bin/fgrep pattern Specifies one or more patterns to be used during the search for input. This operand is treated as if it were specified as -e pattern_list. USAGE
See largefile(5) for the description of the behavior of fgrep when encountering files greater than or equal to 2 Gbyte ( 2^31 bytes). ENVIRONMENT VARIABLES
See environ(5) for descriptions of the following environment variables that affect the execution of fgrep: LC_COLLATE, LC_CTYPE, LC_MES- SAGES, and NLSPATH. EXIT STATUS
The following exit values are returned: 0 If any matches are found 1 If no matches are found 2 For syntax errors or inaccessible files, even if matches were found. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: /usr/bin/fgrep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ /usr/xpg4/bin/fgrep +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWxcu4 | +-----------------------------+-----------------------------+ |CSI |Enabled | +-----------------------------+-----------------------------+ SEE ALSO
ed(1), egrep(1), grep(1), sed(1), sh(1), attributes(5), environ(5), largefile(5), XPG4(5) NOTES
Ideally, there should be only one grep command, but there is not a single algorithm that spans a wide enough range of space-time tradeoffs. Lines are limited only by the size of the available virtual memory. /usr/xpg4/bin/fgrep The /usr/xpg4/bin/fgrep utility is identical to /usr/xpg4/bin/grep -F (see grep(1)). Portable applications should use /usr/xpg4/bin/grep -F. SunOS 5.11 24 Mar 2006 fgrep(1)
All times are GMT -4. The time now is 11:55 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy