Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
A versatile member of the grep family, the non-standard cgrep, allows matches across newlines (among many other extended features, such as extracting windows of lines around matches). For example:
producing:
The cgrep code usually needs to be obtained and compiled. I have done so on 32-bit and 64-bit systems without trouble. See the script comment for the source URL.
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
For portability (but not performance), there is a perl version of grep, peg, that has many features, including the ability to use perl expressions and functions. The near functions allow one to look backwards from a line which matched a pattern, effectively matching across lines:
producing:
The peg code has many of the same basic options as GNU grep, in addition to a number of extensions. For basic work on systems that do not have GNU grep it seems to be an acceptable substitute in many situations. The comment in the shell script points to the code source.
--
On Solaris use /usr/xpg4/bin/awk rather than awk
I am using this command:-awk 'FNR==1{p=1} /ST\*820/{p=0} !p && /RITE AID/{print FILENAME}' natriter820u.20140914 but getting an error.
awk: syntax error near line 1
awk: bailing out near line 1
I am very new to this stuff so if you can please suggest what I am doing wrong here then it will be very helpful
I did and with same syntax error, I think either I am missing something basic here or it is my system limitations.
Here is what I tried:-
and I got the same syntax error
Heyas
I'm trying to read/display a file its content and put borders around it (tui-cat / tui-cat -t(ypwriter).
The typewriter-part is a 'bonus' but still has its own flaws, but thats for later.
So in some way, i'm trying to rewrite cat using bash and other commands.
But sadly it fails on... (2 Replies)
Dear Concern,
When we using @ sign, line breaks for a particular user in shell. Please advise how to resolve from the problem in HP UX.
tabs@tabsdb02:/ccbs/users/tabs$ cat /etc/passwd|grep tabs
tabs:RdCgOsmKee7Ps:221:201::/ccbs/users/tabs:/usr/bin/ksh... (3 Replies)
I am using a grep command with two patterns in my KSH script. File has line breaks in it and both the patterns are in different lines. Here is the command - grep -l 'RITE AID.*ST.820' natriter820u.20140914
Pattern1 - RITE AID
Pattern2 - ST*820
I am not getting any results from this,... (3 Replies)
Hi All,
Need an urgent solution to an issue . We have created a ksh file or shell script which generates 1 DAT file. the DAT file contains extract of a select statement .
Now the issue is , when we are executing the ksh file , the output is coimng with page breaks and line breaks .
We have... (4 Replies)
Hello,
I want to keep line spaces in comments but clean more then 2 after each.
Example:
$sentence="This is my first sentence
This will be in a new row
This will be too in a new row but not separated with 3line breaks just with
one
";
And i want to... (1 Reply)
I need to read temp.$i file content line by line through while loop but somehow the '\' do not appear in output.. Can someone guide how to read this exact content line by line in unix :
if
then
cat temp.$i | head -1 # the file content appears fine
while... (13 Replies)
Hi everyone,
I have gone through the forum trying to find an answer to this question but was unsuccessful. I am hoping that someone can help me with this please.
I am trying to get my script to recognise line breaks from a file and to give me a result for wc of each line. So basically, if you... (7 Replies)
Hi,
I got some log files which print the whole xml message in separate lines:
e.g.
2008-10-01 14:21:44,561 INFO do something
2008-10-01 14:21:44,561 INFO print xml : <?xml version="1.0" encoding="UTF-8"?>
<a>
<b>my data</b>
</a>
2008-10-01 14:21:44,563 INFO do something again
I want... (3 Replies)
In file.name, I have a line that reads
$IDIR/imgen -usemonths -dropcheck -monitor -sizelimit 80000000 -interval 120 -volcal HSI
How can I get the size limit, i.e. 80000000 out and pass it to a variable called SIZE?
Thanks. I tried
echo "grep sizelimit file.name" | sed -n -e... (3 Replies)