Sponsored Content
Top Forums Shell Programming and Scripting How set filter netstat -an | grep -P '\:'38'' Post 302552308 by ostapv on Friday 2nd of September 2011 10:19:42 AM
Old 09-02-2011
Network How set filter netstat -an | grep -P '\:'38''

Hi,

I can write sh script for Linux platform
I run:
Code:
netstat -an | grep -P '\:'38''| grep ESTABLISHED

but result:

Code:
[root@om910 install]# netstat -an | grep -P '\:'38''| grep ESTABLISHED
tcp        0      0 172.16.1.107:383            172.16.1.81:49981           ESTABLISHED
tcp        0      0 127.0.0.1:18170             127.0.0.1:383               ESTABLISHED
tcp        0      0 127.0.0.1:383               127.0.0.1:10555             ESTABLISHED
tcp        0      0 127.0.0.1:10555             127.0.0.1:383               ESTABLISHED
tcp        0      0 127.0.0.1:10329             127.0.0.1:383               ESTABLISHED
tcp        0      0 127.0.0.1:383               127.0.0.1:10329             ESTABLISHED
tcp        0      0 127.0.0.1:383               127.0.0.1:47234             ESTABLISHED


It is not good, because i need to receive only 38 number. How provide it? Thanks

Last edited by pludi; 09-02-2011 at 01:45 PM..
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

need help on netstat -na |grep

Hi, I use the following cmd to view list of clients connected to my HPUX server netstat -na |grep Can anyone help me with the UNIX cmds to find list of clients connected to my HPUX server including idle time. Any help will be highly appreciated. Thanks MH (2 Replies)
Discussion started by: mhbd
2 Replies

2. Programming

Libpcap: Set a filter. (C)

Hi I'm reading about the libpcap documentation. I see that with the function: pcap_setfilter ( pcap_t *p, struct bpf_program *fp) we can choose to take one packet instead another. I read that the struct bpf_program allow us to create a packet filter , ....so if I want just sample some... (2 Replies)
Discussion started by: Dedalus
2 Replies

3. Shell Programming and Scripting

Filter on a grep

I am attempting to figure out how to only capture part of a grep command I am doing. So far no luck. When I execute.... leviathan:/gfs/home/tivoli>ps -ef | /usr/ucb/ps -auxww | grep nco_p_syslog The results are.... tivoli 10185 0.0 0.0 5888 5168 ? S Oct 23 0:26... (2 Replies)
Discussion started by: LRoberts
2 Replies

4. UNIX for Dummies Questions & Answers

Command line / script option to filter a data set by values of one column

Hi all! I have a data set in this tab separated format : Label, Value1, Value2 An instance is "data.txt" : 0 1 1 -1 2 3 0 2 2 I would like to parse this data set and generate two files, one that has only data with the label 0 and the other with label -1, so my outputs should be, for... (1 Reply)
Discussion started by: gnat01
1 Replies

5. Shell Programming and Scripting

awk script to filter the numbers which are around the set value

Hi All, I have one sensor output(over the same) for a set value of 20. Time(in Sec), Data 1, 16 2, 20 3, 24 4, 22 5, 21 6, 20 7, 19.5 8, 20 9, 20.5 10, 20 11, 20 12, 19.5 Here we can see like after 5 sec of time the data value reaches to 20+-0.5 range. So I... (7 Replies)
Discussion started by: ks_reddy
7 Replies

6. Shell Programming and Scripting

netstat grep regex suspend script help

Hi I am trying to create a suspend script which will suspend the system only if it cant find port 9982 four or more times OR 192.168.0.:microsoft-ds ESTABLISHED in the output of netstat -t. I am struggling with the 9982 bit, googling etc I came up with if netstat -t|grep -P "(9982){4,}" ... (15 Replies)
Discussion started by: bilboNIX
15 Replies

7. Shell Programming and Scripting

awk : Filter a set of data to parse header line and last field of multiple same match.

Hi Experts, I have a data with multiple entry , I want to filter PKG= & the last column "00060110" or "00088150" in the output file: ############################################################################################### PKG= P8SDB :: VGS = vgP8SOra vgP8SDB1 vgP8S001... (5 Replies)
Discussion started by: rveri
5 Replies

8. Shell Programming and Scripting

Grep regex filter

Hi, How can I run the grep search in a script to only include compute, not bigcomputer in following search input? " properties = local compute" " properties = local bigcompute" Thank you. -j (6 Replies)
Discussion started by: hce
6 Replies

9. AIX

How to grep PID and program name from netstat in AIX?

Hi All, I am using netstat on AIX to grep info on all open connections. However, unlike on Linux(Centos), I do not get the PID and program name using netstat on AIX. I need this info to be clubbed along with the information retrieved using netstat version of AIX. Is there a way this can be... (1 Reply)
Discussion started by: Vipin Batra
1 Replies

10. UNIX for Beginners Questions & Answers

Need to filter the result set within 2 time frame

my sample file is like this $cat onefile 05/21/18 13:10:07 ABRT US1CPDAY Status 1 05/21/18 21:18:54 ABRT DailyBackup_VFFPRDAPENTL01 Status 6 05/21/18 21:26:24 ABRT DailyBackup_VFFPRDAPENTL02 Status 6 05/21/18 21:57:36 ABRT DailyBackup_vm-ea1ffpreng01 Status 6... (7 Replies)
Discussion started by: gotamp
7 Replies
SHOREWALL-SECMARKS(5)						  [FIXME: manual]					     SHOREWALL-SECMARKS(5)

NAME
secmarks - Shorewall file SYNOPSIS
/etc/shorewall/secmarks DESCRIPTION
Important Unlike rules in the shorewall-rules[1](5) file, evaluation of rules in this file will continue after a match. So the final secmark for each packet will be the one assigned by the LAST rule that matches. The secmarks file is used to associate an SELinux context with packets. It was added in Shorewall version 4.4.13. The columns in the file are as follows (where the column name is followed by a different name in parentheses, the different name is used in the alternate specification syntax). SECMARK - {SAVE|RESTORE|context|COMMENT comment} SAVE If an SELinux context is associated with the packet, the context is saved in the connection. Normally, the remaining columns should be left blank. RESTORE If an SELinux context is not currently associated with the packet, then the saved context (if any) is associated with the packet. Normally, the remaining columns should be left blank. context An SELinux context. COMMENT The remainder of the line is treated as a comment which is attached to subsequent rules until another COMMENT line is found or until the end of the file is reached. To stop adding comments to rules, use a line with only the word COMMENT. CHAIN:STATE (chain) - {P|I|F|O|T}[:{N|I|NI|E|ER}] This column determines the CHAIN where the SElinux context is to be applied: P - PREROUTING I - INPUT F - FORWARD O - OUTPUT T - POSTROUTING It may be optionally followed by a colon and an indication of the Netfilter connection state(s) at which the context is to be applied: :N - NEW connection :I - INVALID connection :NI - NEW or INVALID connection :E - ESTABLISHED connection :ER - ESTABLISHED or RELATED connection SOURCE - {-interface|[interface:]address-or-range[,address-or-range]...}[exclusion] May be: 1. An interface name - matches traffic entering the firewall on the specified interface. May not be used in classify rules or in rules using the T in the CHAIN column. 2. A comma-separated list of host or network IP addresses or MAC addresses. 3. An interface name followed by a colon (":") followed by a comma-separated list of host or network IP addresses or MAC addresses. MAC addresses must be prefixed with "~" and use "-" as a separator. Example: ~00-A0-C9-15-39-78 You may exclude certain hosts from the set already defined through use of an exclusion (see shorewall-exclusion[2](5)). Addresses may be specified using an ipset name preceded by '+'. DEST - {-|{interface|[interface:]address-or-range[,address-or-range]...}[exclusion] May be: 1. An interface name. May not be used in the PREROUTING or INPUT chains. The interface name may be optionally followed by a colon (":") and an IP address list. 2. A comma-separated list of host or network IP addresses. The list may include ip address ranges if your kernel and iptables include iprange support. You may exclude certain hosts from the set already defined through use of an exclusion (see shorewall-exclusion[2](5)). Addresses may be specified using an ipset name preceded by '+'. PROTO - {-|tcp:syn|ipp2p|ipp2p:udp|ipp2p:all|protocol-number|protocol-name|all} Protocol - ipp2p requires ipp2p match support in your kernel and iptables. PORT(S) (dport) - [-|port-name-number-or-range[,port-name-number-or-range]...] Optional destination Ports. A comma-separated list of Port names (from services(5)), port numbers or port ranges; if the protocol is icmp, this column is interpreted as the destination icmp-type(s). ICMP types may be specified as a numeric type, a numberic type and code separated by a slash (e.g., 3/4), or a typename. See http://www.shorewall.net/configuration_file_basics.htm#ICMP. If the protocol is ipp2p, this column is interpreted as an ipp2p option without the leading "--" (example bit for bit-torrent). If no PORT is given, ipp2p is assumed. This column is ignored if PROTOCOL = all but must be entered if any of the following field is supplied. In that case, it is suggested that this field contain "-" SOURCE PORT(S) (sport) - [-|port-name-number-or-range[,port-name-number-or-range]...] Optional source port(s). If omitted, any source port is acceptable. Specified as a comma-separated list of port names, port numbers or port ranges. USER - [!][user-name-or-number][:group-name-or-number] This optional column may only be non-empty if the SOURCE is the firewall itself. When this column is non-empty, the rule applies only if the program generating the output is running under the effective user and/or group specified (or is NOT running under that id if "!" is given). Examples: joe program must be run by joe :kids program must be run by a member of the 'kids' group !:kids program must not be run by a member of the 'kids' group MARK - [!]value[/mask][:C] Defines a test on the existing packet or connection mark. The rule will match only if the test returns true. If you don't want to define a test but need to specify anything in the following columns, place a "-" in this field. ! Inverts the test (not equal) value Value of the packet or connection mark. mask A mask to be applied to the mark before testing. :C Designates a connection mark. If omitted, the packet mark's value is tested. EXAMPLE
Mark the first incoming packet of a connection on the loopback interface and destined for address 127.0.0.1 and tcp port 3306 with context system_u:object_r:mysqld_t:s0 and save that context in the conntrack table. On subsequent input packets in the connection, set the context from the conntrack table. /etc/shorewall/interfaces: #ZONE INTERFACE BROADCAST OPTIONS - lo - ignore /etc/shorewall/secmarks: #SECMARK CHAIN: SOURCE DEST PROTO DEST SOURCE USER/ MARK # STATE PORT(S) PORT(S) GROUP system_u:object_r:mysqld_packet_t:s0 I:N lo 127.0.0.1 tcp 3306 SAVE I:N lo 127.0.0.1 tcp 3306 RESTORE I:ER FILES
/etc/shorewall/secmarks SEE ALSO
http://james-morris.livejournal.com/11010.html http://shorewall.net/configuration_file_basics.htm#Pairs shorewall(8), shorewall-accounting(5), shorewall-actions(5), shorewall-blacklist(5), shorewall-hosts(5), shorewall_interfaces(5), shorewall-ipsets(5), shorewall-maclist(5), shorewall-masq(5), shorewall-nat(5), shorewall-netmap(5), shorewall-params(5), shorewall-policy(5), shorewall-providers(5), shorewall-proxyarp(5), shorewall-rtrules(5), shorewall-routestopped(5), shorewall-rules(5), shorewall.conf(5), shorewall-tcclasses(5), shorewall-tcdevices(5), shorewall-tcrules(5), shorewall-tos(5), shorewall-tunnels(5), shorewall-zones(5) NOTES
1. shorewall-rules http://www.shorewall.net/manpages/shorewall-rules.html 2. shorewall-exclusion http://www.shorewall.net/manpages/shorewall-exclusion.html [FIXME: source] 06/28/2012 SHOREWALL-SECMARKS(5)
All times are GMT -4. The time now is 03:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy