Sponsored Content
Top Forums Shell Programming and Scripting sed or tr to remove specific group of special characters Post 302605574 by forumbaba on Wednesday 7th of March 2012 07:46:20 PM
Old 03-07-2012
Computer sed or tr to remove specific group of special characters

Hi,
I have a input of the form:
..., word1, word2, word3...

I want out put of the form
word1, word2, word3

I tried echo '..., word1, word2, word3...' | tr -d '...,'

but that takes out the commas in the middle too so I get

word1 word2 word3

but I want the commas in the middle.


So help and Thanks
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

remove special and unicode characters

Hi, How do I remove the lines where special characters or Unicode characters appear? The following query does work but I wonder if there is a better way. cat test.txt | egrep -v '\)|#|,|&|-|\(|\\|\/|\.' The following lines show that my query is incomplete. Warning: The word "*Khan" is... (1 Reply)
Discussion started by: shantanuo
1 Replies

2. Shell Programming and Scripting

Remove special characters from string

Hi there, I'd like to write a script that removes any set of character from any string. The first argument would be the string, the second argument would be the characters to remove. For example: $ myscript "My name's Santiago. What's yours?" "atu" My nme's Snigo. Wh's yors? I wrote the... (11 Replies)
Discussion started by: chebarbudo
11 Replies

3. Shell Programming and Scripting

How to remove special characters from each line?

Hello, Is there a simpler way to remove special characters (color codes) from each lines in a log file? I use sed like in the example below but I think there should be a more simple way to achieve the same result: $ cat -vet file1 ^, , , , Maybe to convert the file somehow? ... (5 Replies)
Discussion started by: majormark
5 Replies

4. UNIX for Dummies Questions & Answers

How to Remove Special Characters

Dear Members, We have a file which contains some special characters. I need to replace these special character by a new line character(\n). The Special character is \x85. I am not sure what this character means and how we can remove it. Any inputs are greatly appreciated. Thanks... (5 Replies)
Discussion started by: sandeep_1105
5 Replies

5. Shell Programming and Scripting

remove special characters

hello all I am writing a perl code and i wish to remove the special characters for text. I wish to remove all extended ascii characters. If the list of special characters is huge, how can i do this using substitute command s/specialcharacters/null/g I really want to code like... (3 Replies)
Discussion started by: vasuarjula
3 Replies

6. Shell Programming and Scripting

Remove string between two special characters

Hi All, I have a variable like AVAIL="\ BACK:bkpstg:testdb3.iad.expertcity.com:backtest|\ #AUTH:authstg:testdb3.iad.expertcity.com:authiapd|\ TEST:authstg:testdb3.iad.expertcity.com:authiapd|\ " What I want to do here is that If a find # before any entry, remove the entire string... (5 Replies)
Discussion started by: engineermayur
5 Replies

7. Shell Programming and Scripting

Remove the special characters from field

Hi, In source data few of columns are having special charates(like *) due to this i am not able to display the data into flat file.it's displaying the some of junk data into the flat file. source dataExample: Address1="XDERFTG * HYJUYTG" how to remove the special charates in a string (2 Replies)
Discussion started by: koti_rama
2 Replies

8. Shell Programming and Scripting

Sed - remove special characters

Hi, I have a file with this line, it's always in the first line: I want to remove these special characters: ´╗┐ file1 ´╗┐\\bar\c$\test2\;3.348.118 Bytes;160 ;3 \\bar\c$\test\;35 Bytes;2 ;1 I want the same file to be only \\bar\c$\test2\;3.348.118 Bytes;160 ;3 \\bar\c$\test\;35... (4 Replies)
Discussion started by: nakaedu
4 Replies

9. Shell Programming and Scripting

How to remove special characters?

Hi Gurus, I have file which contains some unicode charachator like "ü". I want to replace it with some charactors. I searched in internet and got command sed "s/ü/-/g", but I don't know how to type ü in unix command line. Please help me for this one. Thanks in advance (7 Replies)
Discussion started by: ken6503
7 Replies

10. Shell Programming and Scripting

Remove Special Characters Within Text

Hi, I have a "|" delimited file that is exported from a database. There is one column in the file which has description/comments entered by some application user. It has "Control-M" character and "New Line" character in between the text. Hence, when i export the data, this record with the new... (4 Replies)
Discussion started by: tarun.trehan
4 Replies
IPFILTER-DEFS(5)						File Formats Manual						  IPFILTER-DEFS(5)

NAME
/etc/netscript/ipfilter-defs - netscript ipfilter-defs compile definitions directory. DESCRIPTION
This manual page documents briefly the compile definition files that are used by the netscript-compile(8) command from the netscript router/firewall network configuration package. This compiler creates a compiled iptables rules file in /etc/netscript/ipfilter-defs.conf (it is a shell script portion) that is sourced by the netscript netscript(8) command to configure the iptables(8) firewall rules in the kernel. STARTUP COMPILATION
The rules can be compiled and automatically loaded on boot by setting the IPV4_CONFIGURE_SWITCH switch in network.conf(5) to the value of the function used to configure the kernel. Net-compile(8) creates this function as Configure. If this switch is set, the netscript startup will run netscript-compile(8) to make sure everything is up to date and load the rules from /etc/netscript/ipfilter-defs.conf, and the relevant settings in network.conf(5) which are used to establish packet grooming and configure the built in kernel netfilter INPUT and FORWARD chains in the filter table. If compilation fails, the previous rule set is not replaced and it is used instead. See the netscript(8) manpage to see how to load and use backup copies of the rule set. CHAIN STRUCTURE
Each chain in the iptables(8) filter table is set up by a corresponding coonstruction function of the same name as the chain. The chains are laced into the iplcl (which is laced in to the INPUT chain) and ipfwd (laced into FORWARD) chains respectively, and the forwarding con- trol chains are set up to take traffic in both directions, with the destination network/interface and source network/interface being used in the lacing chain, and network protocol and port being tied down in each specific chain. For the new in kernel Linux IPSEC, traffic to and from the VPN can be controlled via the iptables policy match module, if you have it patched and compiled into your kernel and iptables. Future versions of the kernel and iptables should have this included in the distrib- uted source. FILE STRUCTURE
All the files defining the rules set are in the /etc/netscript/ipfilter-defs directory. The network-defs file is used to define the regions and network blocks used in the rest of the rules. The prototypes-defs file is used to define protoype rules that can be referenced elsewhere in the rule set. The prototypes.sh file is used to construct shell functions for the netscript-compile(8) command that can be used in the definitions files. DNAT and SNAT are set up in the dnat-defs and masq-defs files respectively. Any file ending in .def is taken as general rule set input for netscript-compile(8). The files generally take the form of tables, with the columns tab or space seperated. The '#' character is supported for commenting, and comments can be on a line by themselves, or at the end of a configuration line. Everything after the '#' is treated as a comment by the netscript-compile(8) compiler. RULE STRUCTURE
The structure of the rule sets is thus. Each chain is started by calling a shell compilation function, (generally ipv4_compile_chain) to create the chain, with the chain name and source/destination regions as arguments, and each rule in the chain by starting a fresh line with the chain name in the first column. Regions are defined as network interface tuples, and are set up in network-defs. They are syntactically the same as shell script vari- ables, and are used the same way in the .def rule set files. Technically this magic is achieved by using eval within the netscript-com- pile(8) shell script. Any interface name can have either of the keywords =clear or =ipsec tied to them by using the `=' character on the end of the interface name. This is used to specifically match IPSEC traffic, or non-IPSEC traffic going over the interface. Typically you would use this when defining a region, though the syntax is valid elsewhere as well. It is recommended that you use this feature to prevent packet injection from adjacent external sources when setting up iptables rules for VPN tunnel traffic. The regions are given as arguments to the compilation function, with the region always being 2 arguments in network/interface order to the function. Each chain rule in the chain is defined by giving first of all the chain name, then the rule type, and its direction. All columns after the 3rd one are specific to and are defined by the rule type. The direction may have a '-' in it. The rules produced by the compiler use the iptables connection based state tracking. Packet by packet rules will be added later. EXAMPLE
Here is an example of part of a .def file: # Access from Office to internet # - only allow outgoing tcp and UDP # and ping traffic - anything else is most # like a tunneling protocol. # We have VPNs for tunneling ipv4_compile_chain -p 90 offcInet droplog $OFFICE_REGN $INTERNET_REGN offcInet ACCEPT_EST BOTH offcInet ACCEPT_PING L2R offcInet ACCEPT_TCP L2R 1:65535 offcInet ACCEPT_UDP L2R 1:65535 The ACCEPT_EST line accepts packets for ESTABLISHED and RELATED connections to the new ones already accepted. New connections are accepted by the ACCEPT_PING, ACCEPT_TCP, and ACCEPT_UDP rules. Please see the iptables(8) manpage for the details on stateful filtering. COMPILE FUNCTIONS
Unless a function is defined in prototypes.sh, there is only one function provided. However this is not limiting as there is a facility for rule macros, as well as the ability to tell the function to use one of the default base rule sets. If you do define a function in prototypes.sh, be careful to handle all errors to function and command calls as otherwise netscript-com- pile(8) will break, as it runs with set -e set. The only defined compile function for IPv4 is: ipv4_compile_chain [-i] [-n] [-b base-chain] [-p priority] [-s slave-chain] <chain-name> <default-target> <from-net> <from-if> [<to-net> <to-if>] You can see the source region and destination region on the end of it. The default-target is one of RETURN, DROP, droplog, or log. The options to this function are as follows: -i Create an input chain for attaching to iplcl instead of the default forward chain for attaching to ipfwd. -n Don't lace the chain into iplcl or ipfwd. -b base-chain Specify an alternate ruleset chain to use. -s slave-chain Configure/deconfigure this chain as well as the one specified. Useful for adjusting input rule set when manipulating the access chain for an IPsec VPN. -p priority Specify the priority of the chain in the lacing rule set. Priority is between 00 and 99, with 00 at the top of the lacing chain, and 99 at the bottom. This is useful for making sure that host specific rule sets occur before more general network related ones, and for putting Internet related ones at the bottom of the lacing chain. DIRECTION STATEMENTS
The direction is as per FreeS/WAN - it uses left and right terminology. The possible directions are as follows: L2R|LEFT2RIGHT|INTERNAL2EXTERNAL|INTERN2EXTERN|I2E|INT2EXT Left to Right, Internal to External R2L|RIGHT2LEFT|EXTERNAL2INTERNAL|EXTERN2INTERN|E2I|EXT2INT Right to Left, External to Internal BOTH|- Both directions, aka none or '-'. AVAILABLE CHAIN RULES
Here are the valid chain rules, and the arguments they expect. COMMENT [word1] [word2] ... Insert a comment into the compile shell script. Fill the 3rd column direction in with '-'. MACRO <macro-name> Specify a macro rule set. Rule set must name start with `MACRO_'. Direction again should be `-'. LOG [word1] [word2] ... Insert a logging rule using the given log meesage, or if none given, using the curretlog message for the chain. LOG_MSG [word1] [word2] ... Set the log message for the chain away from the default of `Chain: <chain-name>' or from previous LOG_MSG setting. Up to 26 letters can be used until truncation limit is reached. RESET_LOG_MSG Reset log message to the default of `Chain: <chain-name>'. REJECT_SMB Jump to smb control chain. Creates smb chain if it does not already exist. DROP_MARTIANS Jump to martian source address control chain. Creates chain if it does not already exist. LOG_PORTSCAN Use the psd module to detect and log portscans. Creates portscan log chain (if not already there) which puts `PORTSCAN DETECTED - ' in the log. DROP_BROADCAST Drop ethernet broadcast packets. LOG_BROADCAST Log ethernet broadcast packets with the current log messages for the chain. ACCEPT_EST Accept ESTABLISH,RELATED packets via the iptables(8) state module. ACCEPT_RELATED Accept RELATED packets via the iptables(8) state module. Useful for ICMP type 3 packets used for maximum MTU detection. ACCEPT_PROTO <protocol> Accept NEW connections for a protocol. Accepts one argument in the 4th column which is the protocol name from /etc/protocols or the protocol number between 0 and 255. REJECT_PROTO <protocol> Reject NEW connections for a protocol with ICMP reject packets. Accepts one argument in the 4th column which is the protocol name from /etc/protocols or the protocol number between 0 and 255. DROP_PROTO <protocol> Drop all packets for a protocol with nothing in reply. Accepts one argument in the 4th column which is the protocol name from /etc/protocols or the protocol number between 0 and 255. LOG_PROTO <protocol> Log NEW connections for a protocol with the current log message for the chain. Accepts one argument in the 4th column which is the protocol name from /etc/protocols or the protocol number between 0 and 255. ACCEPT_TCP [src-port-range] <dst-port-range> Accept NEW TCP connections. If one argument given, it is the destinaion port (range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. REJECT_TCP [src-port-range] <dst-port-range> Reject NEW TCP connections with an ICMP REJECT packet. If one argument given, it is the destination port(range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. DROP_TCP [src-port-range] <dst-port-range> Drop all tcp packets, returning nothing at all. If one argument given, it is the destinaion port (range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. LOG_TCP [src-port-range] <dst-port-range> Log NEW TCP connections with the current log text for the chain. If one argument given, it is the destination port(range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. ACCEPT_UDP [src-port-range] <dst-port-range> Accept NEW UDP connections. If one argument given, it is the destinaion port (range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. REJECT_UDP [src-port-range] <dst-port-range> Reject NEW UDP connections with an ICMP REJECT packet. If one argument given, it is the destination port(range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. DROP_UDP [src-port-range] <dst-port-range> DROP all UDP packets, returning nothing at all. If one argument given, it is the destinaion port (range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. LOG_UDP [src-port-range] <dst-port-range> Log NEW UDP connections with the current log message for the chain. If one argument given, it is the destination port(range). If 2 arguments, the first is the source port (range), and second the destination port (range). Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. ACCEPT_PING Accept ICMP type 8 echo request packets for network diagnosis. DROP_PING Drop ICMP type 8 packets with no reply. LOG_PING Log an ICMP echo request with the current log message for the chain. ACCEPT_TCP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Accept NEW TCP connections from given source (optional) to destination. Network is given in IPv4 address/netmask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. REJECT_TCP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Reject NEW TCP conections with an ICMP reject packet which come from a given source (optional), going to given destination. Network is given in IPv4 address/netmask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. DROP_TCP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Drop all TCP packets which come from a given source (optional), going to given destination. Network is given in IPv4 address/net- mask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. LOG_TCP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Log all NEW TCP connections from given source (optional) to destination, with the current log message for the chain. Network is given in IPv4 address/netmask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. ACCEPT_UDP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Accept NEW UDP connections from given source (optional) to destination. Network is given in IPv4 address/netmask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. REJECT_UDP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Reject NEW UDP conections with an ICMP reject packet which come from a given source (optional), going to given destination. Network is given in IPv4 address/netmask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. DROP_UDP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Drop all UDP packets which come from a given source (optional), going to given destination. Network is given in IPv4 address/net- mask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. LOG_UDP_NET [src_network [src-port-range]] <dst-network> <dst-port-range> Log all NEW UDP connections from given source (optional) to destination, with the current log message for the chain. Network is given in IPv4 address/netmask or address/masklen format. Port ranges are specified by separating them with a `:' character, and ports must be in the /etc/services file, or a number between 0 and 65535. ACCEPT_IFACE <interface> Accept all incoming NEW connections from an incoming interface. REJECT_IFACE <interface> Reject all incoming NEW conections with an ICMP reject packet, from an interface. DROP_IFACE <interface> Drop all incoming packets from an interface. LOG_IFACE <interface> Log all incoming NEW conections from an interface. ACCEPT_NET <network> Accept all NEW connections from network. Network is given in IPv4 address/netmask or address/masklen format. REJECT_NET <network> Reject all NEW conections from network with an ICMP reject packet. Network is given in IPv4 address/netmask or address/masklen for- mat. DROP_NET <network> Drop all packets from network. Network is given in IPv4 address/netmask or address/masklen format. LOG_NET <network> Log all NEW conections from network. Network is given in IPv4 address/netmask or address/masklen format. FILES
/etc/netscript/ipfilter-defs.conf, /etc/netscript/ipfilter-defs-compiled.conf, /etc/netscript/ipfilter-defs directory. SEE ALSO
netscript-compile(8), iptables(8), ip6tables(8), netscript(8). AUTHOR
This manual page was written by Matthew Grant <grantma@anathoth.gen.nz>, for the Debian GNU/Linux system (but may be used by others). BUGS
I wrote this manpage when I was not half asleep... Some things are missing from this manpage... Dnat documentation is missing but obvious from configuration file. SNAT documentation is missing but obvious from configuration file. March 25, 2003 IPFILTER-DEFS(5)
All times are GMT -4. The time now is 12:53 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy