10-13-2004
egrep and grouping
i am using the c shell on solaris.
directories i'm working with:
ls -1d DIV*
DIV_dental/
DIV_ibc/
DIV_ifc/
DIV_index/
DIV_pharm/
DIV_sectionI/
DIV_sectionI-title/
DIV_sectionI-toc/
DIV_sectionII-title/
DIV_sectionII-toc/
DIV_standing/
DIV_standing-toc/
DIV_title/
DIV_vision/
what i am attempting to do is capture only the directories containing "dental", "vision", or "pharm".
at the command line i can do this via
ls -1d DIV* | egrep 'dental|pharm|vision'
or
ls -1d DIV* | nawk '/dental|vision|pharm/{print $1}'
and so on...
however, in my shell script this does not work (the $grp and $job variables i am using for a path are legit):
foreach div (`ls -1d ${grp}/${job}/DIV* | egrep 'pharm|dental|vision'`)
printf "\t%s..." ${div:t}
end
this gives me ALL directories. if i cut it back to
egrep 'pharm|dental' i get only the pharm and dental directories
i have also tried using awk and nawk in the script, with the same results. my coworker has advised me to try something with find, which i will, but i am curious to why this is happening.
thanks for your assistance.
Last edited by effigy; 10-14-2004 at 01:41 AM..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
Hi I've been searching google and have not found what egrep -c means. Does anyone know where I can get a cheat sheet or what that -c means?
thanks,
Linda (2 Replies)
Discussion started by: leelm
2 Replies
2. UNIX for Dummies Questions & Answers
Hi Guys,
we have a shell script which basically query the Database which retrieves huge data and use the data with "egrep" .
Now there is some data which contains characters like "abc)" and the same is used like below :
"egrep (.+\|GDPRAB16\|GDPR/11702 96 abc)\|$ temp.txt"
now while... (7 Replies)
Discussion started by: sagarjani
7 Replies
3. UNIX for Advanced & Expert Users
I am new to the unix server.
My question is:
i have 10 users
a
b
c
d
e
f
g
h
i
j
Among the 10 5 users are (normal) user and remainging 5 users are (qad) users
How can i sepearte this one?
How can i give the dlc access rights?
Please provide the clear cut idea. (0 Replies)
Discussion started by: kingganesh04
0 Replies
4. UNIX for Dummies Questions & Answers
how would I write a command line that creates a new file named stuff.txt in the current working directory which contains the number of directories in the current working directory, followed by the number of empty files in the current working directory, followed by the name of the working directory? (3 Replies)
Discussion started by: jorogon0099
3 Replies
5. UNIX for Dummies Questions & Answers
Hi all,
I have a set data as shown below, and i would like to eliminate the name that no children - boy and girl. What is the appropriate command can i use(other than grep)? Please assist...
My input:
name sex marital status children - boy children - girl ... (3 Replies)
Discussion started by: 793589
3 Replies
6. UNIX for Advanced & Expert Users
Hi all,
I have input lines like below:
A;100;Paris;City;10;0;0
A;100;Paris;City;0;10;0
A;100;Paris;City in Europe;0;0;20
B;101;London;City;20;0;0
B;101;London;City;0;20;0
B;101;London;City in Europe;0;0;40
I need to group the above lines to:
A;100;Paris;City in Europe;10;10;20... (4 Replies)
Discussion started by: andy2000
4 Replies
7. Shell Programming and Scripting
Whats a good way to group (by adding a new integer to the front of each line) pairs of lines, such that lines 1 & 2 are group 1, lines 3 & 4 are group 2, etc...
ex input:
A
B
C
D
etc...
ex output:
1A
1B
2C
2D
etc... (5 Replies)
Discussion started by: watingo
5 Replies
8. UNIX for Dummies Questions & Answers
How do you do grouping in grep? Here's how I tried it at first:
egrep 'qualit(y|ies)' /usr/share/dict/words
-bash: syntax error near unexpected token `('
I'm using GNUgrep, and I found this on their site. grep regular expression syntax
So I tried this:
egrep 'qualit\(y\|ies\)'... (2 Replies)
Discussion started by: sudon't
2 Replies
9. Shell Programming and Scripting
Hi all,
I am using following command:
perl program.pl input.txt output.txt CUTOFF 3 > groups_3.txt
containing program.pl, two files (input.txt, output.txt) and getting output in groups_3.txt:
But, I wish to have 30 files corresponding to each CUTOFF ranging from 0 to 30 using the same... (1 Reply)
Discussion started by: bioinfo
1 Replies
10. Shell Programming and Scripting
awk 'FNR==NR {a; next} $NF in a' genes.txt refseq_exons.txt > output.txt
I can not figure out how to group the same name in $4 together.
Basically, all the SKI together in separate rows and all the TGFB2. Thank you :).
chr1 2160133 2161174 SKI
chr1 218518675 218520389 TGFB2... (1 Reply)
Discussion started by: cmccabe
1 Replies
DIV(3) Linux Programmer's Manual DIV(3)
NAME
div, ldiv, lldiv, imaxdiv - compute quotient and remainder of an integer division
SYNOPSIS
#include <stdlib.h>
div_t div(int numerator, int denominator);
ldiv_t ldiv(long numerator, long denominator);
lldiv_t lldiv(long long numerator, long long denominator);
#include <inttypes.h>
imaxdiv_t imaxdiv(intmax_t numerator, intmax_t denominator);
Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
lldiv():
_XOPEN_SOURCE >= 600 || _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L;
or cc -std=c99
DESCRIPTION
The div() function computes the value numerator/denominator and returns the quotient and remainder in a structure named div_t that contains
two integer members (in unspecified order) named quot and rem. The quotient is rounded toward zero. The result satisfies quot*denomina-
tor+rem = numerator.
The ldiv(), lldiv(), and imaxdiv() functions do the same, dividing numbers of the indicated type and returning the result in a structure of
the indicated name, in all cases with fields quot and rem of the same type as the function arguments.
RETURN VALUE
The div_t (etc.) structure.
ATTRIBUTES
Multithreading (see pthreads(7))
The div(), ldiv(), lldiv(), and imaxdiv() functions are thread-safe.
CONFORMING TO
SVr4, 4.3BSD, C89. C99. The functions lldiv() and imaxdiv() were added in C99.
EXAMPLE
After
div_t q = div(-5, 3);
the values q.quot and q.rem are -1 and -2, respectively.
SEE ALSO
abs(3), remainder(3)
COLOPHON
This page is part of release 3.53 of the Linux man-pages project. A description of the project, and information about reporting bugs, can
be found at http://www.kernel.org/doc/man-pages/.
2013-07-05 DIV(3)