1833093 Members
2980 Online
110050 Solutions
New Discussion

Shell script.

 
Gulam Mohiuddin
Regular Advisor

Shell script.

Following is the output of the ipcs command:

# ipcs -mob |sort -k 5

Shared Memory:
T ID KEY MODE OWNER GROUP NATTCH SEGSZ
m 537 0x441806fc --rw-r--rw- root sys 0 13812
m 3093 0x491806fc --rw-r--rw- root sys 0 16344
m 26 0x411806fc --rw-r--rw- root sys 1 4508024
m 23 0xe0da3354 --rw-r----- ora816 dba 6 36040704
m 20504 0xa122aef0 --rw-r----- ora816 dba 6 81096704
m 11803 0x6a7dfce7 --rw-r----- oracle dba 6 8290304
m 12304 0x55fef118 --rw-r----- oracle dba 7 5439488
IPC status from /dev/kmem as of Mon Mar 19 11:09:21 2001


But I want the output without the headers and footers like:

m 537 0x441806fc --rw-r--rw- root sys 0 13812
m 3093 0x491806fc --rw-r--rw- root sys 0 16344
m 26 0x411806fc --rw-r--rw- root sys 1 4508024
m 23 0xe0da3354 --rw-r----- ora816 dba 6 36040704
m 20504 0xa122aef0 --rw-r----- ora816 dba 6 81096704
m 11803 0x6a7dfce7 --rw-r----- oracle dba 6 8290304
m 12304 0x55fef118 --rw-r----- oracle dba 7 5439488

How to get this output.

Thanks.
Everyday Learning.
6 REPLIES 6
Dieter Degrendele_1
Frequent Advisor

Re: Shell script.

Hi,

Take a look at following commands:

head
tail

Rgds,
DD
The possible we did, the unpossible we're doing but for a miracle you have to wait some time.
James A. Donovan
Honored Contributor

Re: Shell script.

You can use sed to strip off the first three lines of output from the ipcs command

# ipcs -mob |sed -e '1,3d' |sort -k 5
m 1031 0x0000cace --rw-rw-rw- root root 0 2
m 0 0x411c0232 --rw-rw-rw- root root 0 348
m 6 0x53494152 --rw-r--r-- root root 1 512
m 4 0x55315352 --rw-rw-rw- root root 1 4096
m 2 0x41200891 --rw-rw-rw- root root 1 8192
m 1 0x4e0c0002 --rw-rw-rw- root root 1 31040
m 3 0x4d4e5251 --rw-r--r-- root root 3 109568
m 5 0x44525354 --rw-r--r-- root root 4 393216
m 130568 0x5f36545a --rw-rw---- oracle dba 131 735166464
Remember, wherever you go, there you are...
Wilfred Chau_1
Respected Contributor

Re: Shell script.

pipe to awk;
awk '/^m/{print}'
print line starting with a "m"
Patrick Wallek
Honored Contributor

Re: Shell script.

You could also use grep.
Rodney Hills
Honored Contributor

Re: Shell script.

The 'sed' command can do it too-

ipcs -mob | sed -e '1d;$d'
There be dragons...
Satish Y
Trusted Contributor

Re: Shell script.

Hi,

Try this,
# ipcs -mob |sort -k 5 | grep -Ev '^Shared|^T|^IPC'

In above "^" means begins with
u can add more strings in single quotes using "|" symbol.

u can also use:
# ipcs -mob |sort -k 5 | grep "^m "


Cheers...
Satish.
Difference between good and the best is only a little effort