Sponsored Content
Top Forums Shell Programming and Scripting Issue executing grep command on Solaris Post 302974446 by Corona688 on Monday 30th of May 2016 06:42:44 PM
Old 05-30-2016
If you don't want to install GNU grep, a crude simulacrum can be made in awk.
Code:
$ cat bam

1
2
3
4
5
BAM
5
4
3
2
1

$ cat ctx.awk

BEGIN {
        B=0;    A=0;    MAX=100;        LAST=0; P=0
}

function last(N)
{
        if(N>L) return("");
        return(LINE[(L-N)%MAX]);
}

{ LINE[(++L)%MAX]=$0 } # Remember line for later

($0 ~ PAT) {
        if((NR - LAST) > B)     LAST = (NR-B);

        P=A+1

        while(LAST <= NR)
        {
                print last(NR-LAST);
                LAST++;
        }
        next
}

((--P)>0)

$ nawk -f ctx.awk PAT="BAM" B=1 A=3 bam

5
BAM
5
4
3

$

 

10 More Discussions You Might Find Interesting

1. Solaris

Troubles building on solaris 9 and executing on solaris 10

Hi, I have to build an application on solaris 9 which is supposed to run on solaris 10 computers. I heard that solaris 9 builds should run on solaris 10 without any troubles. However, there is some trouble. Calling ldd on the programm reveals that "libgcc_s.so.1" and "libstdc++.so.6" are... (4 Replies)
Discussion started by: mikehammer80
4 Replies

2. Shell Programming and Scripting

issue with grep command

i am using 'psu' to grep the status of a process like below :- psu|grep -i agentf 29559 29552 0 00:53:05 ? 0:57 gn1avm_agent -n AGENTF1 28946 1 0 00:51:31 ? 0:31 gnavm_ewd -b gn1avm_agent -n AGENTF1 -c -n AGENTF1 29552 28946 0 00:53:05 ? 0:00 /bin/ksh... (6 Replies)
Discussion started by: deepakiniimt
6 Replies

3. HP-UX

Performance issue with 'grep' command for huge file size

I have 2 files; one file (say, details.txt) contains the details of employees and another file (say, emp.txt) has some selected employee names. I am extracting employee details from details.txt by using emp.txt and the corresponding code is: while read line do emp_name=`echo $line` grep -e... (7 Replies)
Discussion started by: arb_1984
7 Replies

4. UNIX for Dummies Questions & Answers

Grep command issue

How am I supposed to print with one Unix command the names (and only the names) of company JMT? Problems with scandinavian letters? By typing grep JMT url | egrep --only-matching ']+'I still have company name and + marks I should get rid of. I'd be very grateful of your help bacause I am new... (1 Reply)
Discussion started by: jht
1 Replies

5. Shell Programming and Scripting

CUT Command and grep issue

I am trying to grep the oracle erros evry day from the logs file. My problem is : -rw-r----- 1 tibcolm tibco 17438361 Apr 5 11:59 RetryService-RetryService.log -rw-r----- 1 tibcolm tibco 245303 Apr 5 12:00 ResponseService-ResponseService.log -rw-r----- 1 tibcolm tibco 2122654 Apr 5 12:00... (4 Replies)
Discussion started by: neeraj617
4 Replies

6. Shell Programming and Scripting

Issue while executing script

Hi, I'm trying to use the below command in a shell script, but couldn't. The command is working fine when I'm executing from the dollar prompt i.e. shell. Command: grep -i fail /home/applmgr/error.log |egrep -i "`date --date="-4 day" +"%m/%d/%Y"`|`date --date="-4 day" +"%m/%d/%y"`"... (8 Replies)
Discussion started by: venkatesh17
8 Replies

7. UNIX for Dummies Questions & Answers

grep issue (Solaris)

Can anyone explain this (i.e. why the 2nd grep does not find anything)?: -bash-3.00$ cat tmp.log sftp> chdir /home/test-dir sftp> mget thosefiles*.txt File "/home/test-dir/thosefiles*.txt" not found. -bash-3.00$ grep "s*.txt" tmp.log sftp> mget thosefiles*.txt File... (4 Replies)
Discussion started by: dhebden
4 Replies

8. Shell Programming and Scripting

Issue when executing shc command

Hi All, I am trying to create an executable using shc. I have a script which is creating 10 executables. The executables being created have the below issue. The message "Please contact your provider" is displayed even though I am not using the “-e” option. This message is coming for some... (5 Replies)
Discussion started by: temp_user
5 Replies

9. Shell Programming and Scripting

Issue using empty variable in grep command

Hi, I'm writing a shell script and trying to grep a variable value, it works fine as long as there is a value in /tmp/list.out which is captured in $DSK but sometimes the file tends to be empty and that is where I'm having an issue while using grep which returns nothing. I know I can use something... (15 Replies)
Discussion started by: mbak
15 Replies

10. Shell Programming and Scripting

Issue with awk command between Linux and Solaris

Hi, Here is the output using bash profile on Linux uptime 04:59:14 up 16 days, 4:48, 2 users, load average: 1.00, 1.00, 1.20 Here is the output using bash profile on Solaris uptime 4:00am up 84 day(s), 22:21, 3 users, load average: 0.09, 0.10, 0.12 Now,... (4 Replies)
Discussion started by: mohtashims
4 Replies
asadmin-delete-jdbc-connection-pool(1AS)			   User Commands			  asadmin-delete-jdbc-connection-pool(1AS)

NAME
delete-jdbc-connection-pool - removes the JDBC connection pool SYNOPSIS
delete-jdbc-connection-pool --user admin_user [--password admin_password] [--host localhost] [--port 4848] [--secure|-s] [--passwordfile filename] [--terse=false] [--echo=false] [--interactive] [--cascade=false] connection_pool_ID Removes the JDBC connection pool. This command is supported in remote mode only. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. --echo setting to true will echo the command line statement on the standard output. --interactive prompts you for the required options that are not already specified. --cascade If set to true, deletes all the connector resources associated with the pool, apart from the pool itself. If set to false (default), the deletion of the pool fails if there are any resources associated with the pool. Either the resource has to be deleted explicitly, or set the option to true. OPERANDS
connection_pool_id name of the JDBC connection pool to be deleted. Example 1: Using the delete-jdbc-connection-pool command asadmin> delete-jdbc-connection-pool --user admin --password adminadmin --host fuyako port 7070 XA_connection_pool Deleted the JDBC connection pool resource with id = XA_connection_pool Where: the XA_connection_pool resource is deleted. EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-jdbc-connection-pool(1AS), asadmin-list-jdbc-connection-pools(1AS) J2EE 1.4 SDK March 2004 asadmin-delete-jdbc-connection-pool(1AS)
All times are GMT -4. The time now is 11:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy