Sponsored Content
Top Forums Shell Programming and Scripting Grep for string, but within mentioned bounds Post 302965456 by jamie_123 on Friday 29th of January 2016 09:20:27 AM
Old 01-29-2016
Grep for string, but within mentioned bounds

Hi,

I've been trying to filter a file which has several repetitions of lines which looks as follows:

Code:
('hello
My name is
jamie
blabla
xyz>>)

Each line has different values in them. I want grep or awk or sed to treat everything within the (' and >>) as one line and then filter for a single word, for example jamie.

Any ideas how to do this?

PS:

I had tried a solution based on the following awk '/START:/{if (NR!=1)print "";next}{print $0}END{print "";}. However, the output still seems to be in separate lines...

I above gives me a solution as follows:

Code:
My name is
jamie
blabla
xyz>>)

My name is
joan
blabla
blabla
xyz>>)

Is there an easy way to merge lines not separated by a blank line into a single line?
Thanks.

Last edited by jamie_123; 01-29-2016 at 10:50 AM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

crontab: error on previous line; number out of bounds.

Hi, I am trying to set up a cron job for every Friday at 6:00 p.m. and got an error: "/var/tmp/aaaa29638" 1 line, 73 characters 00 18 00 0 5 /app/test/backup.ksh crontab: error on previous line; number out of bounds. Any ideas? Thanks! (1 Reply)
Discussion started by: oradbus
1 Replies

2. Programming

how to avoid the segfault from Address 0x1cd00000103 out of bounds

After allocating memory for some variables, segfault is often to happen, due to the same reason: Address 0x1cd00000103 out of bounds It is welcome to recommend some treatments. Thanks e.g. is_done = 0x1cd00000103 <Address 0x1cd00000103 out of bounds>, hood = 0x23c00000247, c =... (11 Replies)
Discussion started by: cdbug
11 Replies

3. Programming

array bounds and mem leak tool

Is there any freeware to find out array bounds static and dynamic ways in Solaris 10. (1 Reply)
Discussion started by: satish@123
1 Replies

4. UNIX for Dummies Questions & Answers

| help | unix | grep - Can I use grep to return a string with exactly n matches?

Hello, I looking to use grep to return a string with exactly n matches. I'm building off this: ls -aLl /bin | grep '^.\{9\}x' | tr -s ' ' -rwxr-xr-x 1 root root 632816 Nov 25 2008 vi -rwxr-xr-x 1 root root 632816 Nov 25 2008 view -rwxr-xr-x 1 root root 16008 May 25 2008... (7 Replies)
Discussion started by: MykC
7 Replies

5. Shell Programming and Scripting

Grep a string from input file and delete next three lines including the line contains string in xml

Hi, 1_strings file contains $ cat 1_strings /home/$USER/Src /home/Valid /home/Review$ cat myxml <projected value="some string" path="/home/$USER/Src"> <input 1/> <estimate value/> <somestring/> </projected> <few more lines > <projected value="some string" path="/home/$USER/check">... (4 Replies)
Discussion started by: greet_sed
4 Replies

6. Shell Programming and Scripting

grep exact string from files and write to filename when string present in file

I am attempting to grep an exact string from a series of files within a directory and append that output to the filename when it is present in the file. I've been after this all day with no luck. Thanks for your help in advance :wall:. (4 Replies)
Discussion started by: JC_1
4 Replies

7. Shell Programming and Scripting

Grep string in files and list file names that contain the string

Hi, I have a list of zipped files. I want to grep for a string in all files and get a list of file names that contain the string. But without unzipping them before that, more like using something like gzcat. My OS is: SunOS test 5.10 Generic_142900-13 sun4u sparc SUNW,SPARC-Enterprise (8 Replies)
Discussion started by: apenkov
8 Replies

8. Shell Programming and Scripting

Grep for all ip addresses mentioned in all files in a Directory

I wish to traverse all files and folders under a given directory say "/tmp/configuration" and for all ip address mentioned therein. I tried find ./ -type f | xargs grep "*.*.*.*" but it does not populated the correct results. Can you please suggest. (1 Reply)
Discussion started by: mohtashims
1 Replies

9. UNIX for Beginners Questions & Answers

Can I combine below mentioned grep commands using OR (when searching strings having spaces)

Command 1: $script | grep 'Write to ECC( SSID=MARGIN)' Command 2: $script | grep 'is not greater than existing logical processing' The above commands run my script and search the mentioned strings but I do not want to run my script twice. It is increasing run time. Can someone tell me... (3 Replies)
Discussion started by: Tanu
3 Replies

10. Programming

-Warray-bounds option to GCC compiler

What exactly is the -Warray-bounds option to the GCC compiler supposed to warn about? the man page states: ~ g++ --version g++ (GCC) 7.3.1 20180130 (Red Hat 7.3.1-2) Copyright (C) 2017 Free Software Foundation, Inc.Thank you. (14 Replies)
Discussion started by: milhan
14 Replies
SVK::Log::Filter::Grep(3)				User Contributed Perl Documentation				 SVK::Log::Filter::Grep(3)

SYNOPSIS
SVK::Log::Filter::Grep - search log messages for a given pattern DESCRIPTION
The Grep filter requires a single Perl pattern (regular expression) as its argument. The pattern is then applied to the svn:log property of each revision it receives. If the pattern matches, the revision is allowed to continue down the pipeline. If the pattern fails to match, the pipeline immediately skips to the next revision. The pattern is applied with the /i modifier (case insensitivity). If you want case-sensitivity or other modifications to the behavior of your pattern, you must use the "(?imsx-imsx)" extended pattern (see "perldoc perlre" for details). For example, to search for log messages that match exactly the characters "foo" you might use svk log --filter "grep (?-i)foo" However, to search for "foo" without regards for case, one might try svk log --filter "grep foo" The result of any capturing parentheses inside the pattern are not available. If demand dictates, the Grep filter could be modified to place the captured value somewhere in the stash for other filters to access. If the pattern contains a pipe character ('|'), it must be escaped by preceding it with a '' character. Otherwise, the portion of the pattern after the pipe character is interpreted as the name of a log filter. STASH
/PROPERTY MODIFICATIONS Grep leaves all properties and the stash intact. perl v5.10.0 2008-08-04 SVK::Log::Filter::Grep(3)
All times are GMT -4. The time now is 04:50 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy