08-25-2006
Can't get grep to do all the work but a quick little script can do it
Say the script name is showdetails.sh
Usage;
showdetails /path_to/pattern.file /path_to/test.txt
Inside the script....
#!/usr/bin/sh
count=1
for nxt in `cat $1`
do
out[$count]="`grep -c $nxt $2`:$nxt\n"
count=`expr $count + 1`
done
echo ${out[@]} | tr -d "[:blank:]"
XX - END SCRIPT --
The tr will remove the blanks in the out put to get a nice neat colum, try it with the tr function and see.
That should work, if my typing is ok...
Goot go and do some firm upgrades in linux.... wish me luck..
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have the following data:
A
1
2
3
A
4
5
6
A
7
8
9
I want to grep this data with A and 3 lines below it then display them in this format:
A 1 2 3
A 4 5 6
A 7 8 9 (4 Replies)
Discussion started by: bobo
4 Replies
2. UNIX for Dummies Questions & Answers
My file contains the following:
uat2000.aspclient.active=true
uat2001.aspclient.active=true
uat2002.aspclient.active=true
uat2003.aspclient.active=true
uat2004.aspclient.active=false
uat2005.aspclient.active=false
uat2006.aspclient.active=false
uat2007.aspclient.active=false... (8 Replies)
Discussion started by: kthatch
8 Replies
3. Shell Programming and Scripting
Hi Guru's.... I've one log file in all my systems which writes the backup information..
I'have written a command like this:
ssh -l ora${sid} ${primaryhost} "tail -50 /oracle/$ORACLE_SID/newbackup/END_BACKUP.log" |grep 'insert' |tail -1| awk '{print $7}'
We have nearly 50 systems in our... (2 Replies)
Discussion started by: suri.tyson
2 Replies
4. Shell Programming and Scripting
Folks, is it possible to display only words with grep (or any built-in ultility)?
I have more than 1 pattern to search, say apple & orange
The text goes like this:
So I need to display all the words starting with apple or orange
The output should be:
Any idea? (7 Replies)
Discussion started by: bsddaemon
7 Replies
5. Solaris
Hi
is there a way in grep to display few lines before and after the pattern??
I tried options A and B and after-context and before-context. But they don't work on Solaris platform.
please advise. (13 Replies)
Discussion started by: melanie_pfefer
13 Replies
6. AIX
I use grep to check for a string that validates data in a file, it works great but the problem is that the file is becoming too big and gerp has started hurting the response time to users. Since I only need to find the first occurrence I have been looking for ways to stop grep for scanning the rest... (8 Replies)
Discussion started by: mpoblete
8 Replies
7. UNIX for Dummies Questions & Answers
/usr/xpg4/bin/grep -e "Type" / datarecords.txt
output
datarecords.txt: male | datarecords.txt: male | datarecords.txt: female
i wanna the output to be
:male | :male | :female
at the end not to appear the filename fom grep command :D :D (3 Replies)
Discussion started by: teefa
3 Replies
8. UNIX for Advanced & Expert Users
I have a file against which I can grep a string for. I can also check for that string count using wc -l (or grep -c). I need to display the results of both in one output i.e. 'line containing string' and 'count' - what would be the most efficient way of managing this? Thanks in advance. (3 Replies)
Discussion started by: haider1
3 Replies
9. Shell Programming and Scripting
i have this line of code that looks for the same file if it is currently running and returns the count.
`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh | grep -v grep | wc -l`
basically it is assigned to a variable
ISRUNNING=`ps -eaf -o args | grep -i sfs_pcard_load_file.ksh |... (6 Replies)
Discussion started by: wtolentino
6 Replies
10. UNIX for Dummies Questions & Answers
How would I do the following :
Records other than ”ATOM”,”CONNECT”, ”HETATM”, ”TER” and ”END” are considered header records which describe the metadata about the molecule. Use grep to generate the header.
I have this chemistry database. On the attachment. But I am not sure how to use... (4 Replies)
Discussion started by: homeylova223
4 Replies
lptest(1B) SunOS/BSD Compatibility Package Commands lptest(1B)
NAME
lptest - generate line printer ripple pattern
SYNOPSIS
/usr/ucb/lptest [ length [count]]
DESCRIPTION
The lptest utility writes the traditional ripple test pattern to the standard output. In 96 lines, the ripple test pattern prints all 96
printable ASCII characters in each position. The ripple test pattern was originally created to test printers. It is also useful for test-
ing terminals, driving terminal ports, debugging, and performing tasks that require a quick supply of random data.
This command is obsolete.
OPTIONS
length Specifies the length of the output line in characters. 79 characters is the default.
count Specifies the number of output lines. 200 lines is the default. If count is specified, length must also be specified.
EXIT STATUS
The following exit values are returned:
0 Successful completion.
non-zero An error occurred.
ATTRIBUTES
See attributes(5) for descriptions of the following attributes:
+-----------------------------+-----------------------------+
| ATTRIBUTE TYPE | ATTRIBUTE VALUE |
+-----------------------------+-----------------------------+
|Availability |SUNWscplp |
+-----------------------------+-----------------------------+
SEE ALSO
attributes(5)
SunOS 5.10 9 Sep 1996 lptest(1B)