How to use regexp to print out repetitive pattern in awk?
output:
I tried following which does not give what I want, of course.
output:
Any help, please? Thanks in advance!
the data file is as below:
> cat master.cnf
/usr| location for usr|5
/src/ver1| version 1 |10
/src/ver2/log| ver 2 log |25
/src/sys/apps/log| Application log for sys|36
/src/sys/apps/conf| configuration location for app|45
/src/sys/apps/bin| binary location app|55my script is as below:
... (1 Reply)
Good Day,
Im new to scripting especially awk and sed. I just would like to ask help from you guys about a sed command that prints the line immediately after a regexp, but not the line containing the regexp.
sed -n '/regexp/{n;p;}' filename
What if my regexp is 3 word or a sentence. Im... (3 Replies)
Hi,
I know how to use awk to search some expressions like five consecutive numbers, , this is easy.
However, how do I make awk print the pattern that is been matched?
For example:
input: usa,canada99292,japan222,france59664,egypt223
output:99292,59664 (6 Replies)
Hi users
I have one file which has number of occurrence of one pattern
examples
Adjustmenttype,11
xyz 10
dwe 9
abd 13
def 14
Adjustmenttype,11
xyz 24
dwe 34
abd 35
def 11
nmb 12
Adjustmenttype, not eleven
....
...
... (2 Replies)
I am trying to print text between two variables in a file
I have tried the following things but none seem to work:
awk ' /'$a'/ {flag=1;next} /'$b'/{flag=0} flag { print }' file
and also
sed "/$a/,/$b/p" file
But none seem to work
Any Ideas?
Thanks in Advance (5 Replies)
I wanted to get outcome from a big file with pattern quoted:
Line FSP LSP SR RL
Test1 100 300 4 4000
Test2 1 300 2 300
Any help is greatly appreciated. Thank you. (15 Replies)
Hello all
According to the following file (orignal one contains 200x times the same structure...) I was wondering if someone could help me to print <byte>??</byte> values
example, running this script/command like
./script.sh xxapp
I would expect as output: 102 116 112
./script.sh xxapp2... (2 Replies)
Hi,
Do anybody know how to use awk to count the pattern at specific column?
Input file
M2A928K 419 ath-miR159a,gma-miR159a-3p,ptc-miR159a 60 miR235a
.
.
Output file
M2A928K 419 ath-miR159a,gma-miR159a-3p,ptc-miR159a 60 miR235a 3
.
.
I plan to count how many "miR" in column 3... (2 Replies)
Hi All,
I need to print the characters in the previous line just before the regular expression match
Please have a look at the input file as attached
I need to match the regular expression ^ with the character of the previous like and also the pin numbers
and the output file should be like... (6 Replies)
Discussion started by: kshitij
6 Replies
LEARN ABOUT DEBIAN
plan9-grep
GREP(1) General Commands Manual GREP(1)NAME
grep, g - search a file for a pattern
SYNOPSIS
grep [ option ... ] pattern [ file ... ]
g [ option ... ] pattern [ file ... ]
DESCRIPTION
Grep searches the input files (standard input default) for lines that match the pattern, a regular expression as defined in regexp(7) with
the addition of a newline character as an alternative (substitute for |) with lowest precedence. 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.
-e The following argument is taken as a pattern. This option makes it easy to specify patterns that might confuse argument parsing,
such as -n.
-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.
-f The pattern argument is the name of a file containing regular expressions one per line.
-b Don't buffer the output: write each output line as soon as it is discovered.
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 '...'. An expression starting with '*' will treat the rest of the expression as literal characters.
G invokes grep with -n and forces tagging of output lines by file name. If no files are listed, it searches all files matching
*.C *.b *.c *.h *.m *.cc *.java *.cgi *.pl *.py *.tex *.ms
SOURCE
/src/cmd/grep
/bin/g
SEE ALSO ed(1), awk(1), sed(1), sam(1), regexp(7)DIAGNOSTICS
Exit status is null if any lines are selected, or non-null when no lines are selected or an error occurs.
GREP(1)