Sponsored Content
Top Forums Shell Programming and Scripting Extremely rusty on my scripting and need help! Post 302384482 by Franklin52 on Tuesday 5th of January 2010 12:58:22 PM
Old 01-05-2010
An example how to print the line with the pattern and 3 lines after the pattern:

Code:
awk '/pattern/{p=1}p && c++<=3' file

 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

extremely headache

I need to execute command at remote host from my program. there is rs6000/aix standard command called rexec. unfortunately rexec ask username and password which must supplied interactively, of course it is impossible runned by program. So I have to change rexec command format to make user-name... (5 Replies)
Discussion started by: yatno
5 Replies

2. UNIX for Dummies Questions & Answers

Extremely Interested

As i was reading an article on being a "HACKERS" which was 30 minutes ago thinking that HACKING was the same as CRACKING, after the reading i discovered their difference, a hacker builds the internet while crackers just cracks and annoy like phreaking and breaking into people's computer. That... (5 Replies)
Discussion started by: Punk18
5 Replies

3. UNIX for Dummies Questions & Answers

extremely new to unix, need help

Hi, I'm really new and I need help with UNIX. I'm not sure how to use FILE * fp properly, I don't know how to use loops, I don't know how to using i++ or ++i to do things like count the number of scans and print it out, and I don't know how to call functions and use them. I really only know how to... (1 Reply)
Discussion started by: s2pids2pid
1 Replies

4. UNIX for Dummies Questions & Answers

Extremely New

I just loaded Cygwin on my XP deskop. I am TRYING to install a program that said it needs this program to run. How do I install or run a program? Keep in mind I just started with Unix yesterday:) (1 Reply)
Discussion started by: gss
1 Replies

5. UNIX for Dummies Questions & Answers

help with extremely basic problem

Alright i'm having problems with this loop. Basically once the script is ran a parameter is required. Once entering the parameter it displays that in LIMIT. Alright so now the problem, I need my loop to ask my user for a number, and if that number is less than the limit then sum the input values... (4 Replies)
Discussion started by: tragic54
4 Replies

6. Solaris

Re-sync Taking Extremely Long.

It's almost 3 days now and my resync/re-attach is only at 80%. Is there something I can check in Solaris 10 that would be causing the degradation. It's only a standby machine. My live system completed in 6hrs. (9 Replies)
Discussion started by: ravzter
9 Replies

7. UNIX for Dummies Questions & Answers

rusty with cp command -- how to cp all .doc files with .txt extension

I'm rusty with cp, so I was wondering: is it possible to cp all the .doc files in a folder and make them .txt files? Can you use cp to do that? (3 Replies)
Discussion started by: Straitsfan
3 Replies

8. Programming

Working with extremely large numbers in C

Hi All, I am just curious, not programming anything of my own. I know there are libraries like gmp which does all such things. But I really need to know HOW they do all such things i.e. working with extremely large unimaginable numbers which are beyond the integer limit. They can do add,... (1 Reply)
Discussion started by: shoaibjameel123
1 Replies

9. UNIX for Dummies Questions & Answers

Extremely New to Shell Scripts

I am sorry if this qeustion is silly. (Please see Title of this thread.) Is it possible to build a shell script that 1) runs a nawk command that I know works, to analyze a column of data and 2) after that column is analyzed, if the result is over a certain level, send an email with the... (2 Replies)
Discussion started by: he204035
2 Replies
GREP(1) 						      General Commands Manual							   GREP(1)

NAME
grep - search a file for a pattern SYNOPSIS
grep [ option ... ] pattern [ file ... ] DESCRIPTION
Grep searches the input files (standard input default) for lines (with newlines excluded) that match the pattern, a regular expression as defined in regexp(6). Normally, each line matching the pattern is `selected', and each selected line is copied to the standard output. The options are -c Print only a count of matching lines. -h Do not print file name tags (headers) with output lines. -i Ignore alphabetic case distinctions. The implementation folds into lower case all letters in the pattern and input before interpre- tation. Matched lines are printed in their original form. -l (ell) Print the names of files with selected lines; don't print the lines. -L Print the names of files with no selected lines; the converse of -l. -n Mark each printed line with its line number counted in its file. -s Produce no output, but return status. -v Reverse: print lines that do not match the pattern. Output lines are tagged by file name when there is more than one input file. (To force this tagging, include /dev/null as a file name argument.) Care should be taken when using the shell metacharacters $*[^|()= and newline in pattern; it is safest to enclose the entire expression in single quotes '...'. SOURCE
/sys/src/cmd/grep.c SEE ALSO
ed(1), awk(1), sed(1), sam(1), regexp(6) DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs. GREP(1)
All times are GMT -4. The time now is 03:45 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy