Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Use awk to change an IP format Post 302768449 by MrEddy on Friday 8th of February 2013 02:49:56 PM
Old 02-08-2013
Use awk to change an IP format

Basically I am trying to run a standard output of IP address with a port number into another command but I need to change it from.

74.125.224.194.80 into 74.125.224.194:80

One command wants a period before the port the subsequent one wants a colon.

So is there anyway I can feed 74.125.224.194.80 into awk and have it just substitute a : in for the 4th period it finds?

I can find all kinds of ways to do global substitutions but I don't need all periods to have a : just the last one.

Thanks in advance!
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

change the empty function from the old format to the new format

I have about 300 files which has the function getDBBackend(). How to write a program to change the empty function from the old format to the new format? Old empty function format are either: function getDBBackend() { // Not available } // getDBBackend or: function... (0 Replies)
Discussion started by: powah
0 Replies

2. Shell Programming and Scripting

awk,cut fields by change field format

Hi Everyone, # cat 1.txt 1321631,77770132976455,19,20091001011859,20091001011907 1321631,77770132976455,19,20091001011859,20091001011907 1321631,77770132976455,19,20091001011859,20091001011907 # cat 1.txt | awk -F, '{OFS=",";print $1,$3,$4,$5}' 1321631,19,20091001011859,20091001011907... (7 Replies)
Discussion started by: jimmy_y
7 Replies

3. Shell Programming and Scripting

How can I change is output format by awk ?

Hello, Can you tell me how can I change this format by awk Input 0.2057422D-01 0.2463722D-01 -0.1068047D-02 Output 0.02057422 0.02463722 -0.001068047 Thanks wan (8 Replies)
Discussion started by: wanchem
8 Replies

4. Shell Programming and Scripting

using awk or bash to change the format

tenxun-glibc_code-x86-64-linux-20120713190049.root.tar.bz2 To tenxun-glibc_code-x86-64-linux.root.tar.bz2 (3 Replies)
Discussion started by: yanglei_fage
3 Replies

5. Shell Programming and Scripting

Change a file content format using awk

Hi, i have a file input.txt Continent North America Country USA Capital Washington D.C. Country Canada Capital Ottawa Continent South America Country Argentina Capital Buenos Aires Country Brazil Capital Brasília Coutry Colombia Capital Bogotá and i want to get an output.txt ... (3 Replies)
Discussion started by: fastlane3000
3 Replies

6. Shell Programming and Scripting

awk - change date format

I have below date format in a CSV file. (dd/mm/yyyy) Ex Input: 9/8/2013 Need to convert it into below format (yyyymmdd ) and redirect to new file. Ex Output: 20130809 How do I use awk here to change the format and if leading 0 (zero) is not then add it. Please help. Thanks. (8 Replies)
Discussion started by: vegasluxor
8 Replies

7. UNIX for Dummies Questions & Answers

Des/awk for change format and adding integers in a column of data?

Greetings! I need a quick way to change the format in a table of data Here is an example of the input: 10 72 Value=177 VDB=0.0245 Value4=0,0,171,0 10 274 Value=238 VDB=0.0433 Value4=29,0,205,0 10 312 Value=222 VDB=0.0384 Value4=8,0,190,19 10 540 Value=405 VDB=0.0391 Value4=13,30,153,195... (3 Replies)
Discussion started by: Twinklefingers
3 Replies

8. Shell Programming and Scripting

Datestamp format 2nd change in csv file (awk or sed)

I have a csv file formatted like this: 2014-08-21 18:06:26,A,B,12345,123,C,1232,26/08/14 18:07and I'm trying to change it to MM/DD/YYYY HH:MM for both occurances. I have got this: awk -F, 'NR <=1 {print;next}{"date +%d/%m/%Y\" \"%H:%m -d\""$1 "\""| getline dte;$1=dte}1' OFS="," test.csvThis... (6 Replies)
Discussion started by: say170
6 Replies

9. Shell Programming and Scripting

Need to change date format in a csv file using awk

Example: Input csv file 00245DLS,Sitel Ocala,12/31/2014,18:45,1.00,7.00,0.00,0.00 00245DLS,Sitel Ocala,12/31/2014,19:00,-1.00,-1.00,-1.00,-1.00 00245HB,Charlotte,01/01/2015,00:00,-1.00,-1.00,-1.00,0.00 Output csv file 00245DLS,Sitel Ocala,2014/12/31,18:45,1.00,7.00,0.00,0.00 00245DLS,Sitel... (8 Replies)
Discussion started by: adit
8 Replies

10. UNIX for Beginners Questions & Answers

Date format conversion how to change this from using nawk to awk

Hi, I have a file where I need to change the date format on the nth field from DD-MM-YYYY to YYYY-MM-DD so I can accurately sort the record by dates From regex - Use sed or awk to fix date format - Stack Overflow, I found an example using nawk. Test run as below: $: cat xyz.txt A ... (2 Replies)
Discussion started by: newbie_01
2 Replies
RINETD(8)						    BSD System Manager's Manual 						 RINETD(8)

NAME
rinetd -- internet ``redirection server'' SYNOPSIS
/usr/sbin/rinetd VERSION
Version 0.62, 04/14/2003. DESCRIPTION
rinetd redirects TCP connections from one IP address and port to another. rinetd is a single-process server which handles any number of con- nections to the address/port pairs specified in the file /etc/rinetd.conf. Since rinetd runs as a single process using nonblocking I/O, it is able to redirect a large number of connections without a severe impact on the machine. This makes it practical to run TCP services on machines inside an IP masquerading firewall. rinetd does not redirect FTP, because FTP requires more than one socket. rinetd is typically launched at boot time, using the following syntax: /usr/sbin/rinetd The configuration file is found in the file /etc/rinetd.conf, unless another file is specified using the -c command line option. FORWARDING RULES
Most entries in the configuration file are forwarding rules. The format of a forwarding rule is as follows: bindaddress bindport connectaddress connectport For example: 206.125.69.81 80 10.1.1.2 80 Would redirect all connections to port 80 of the "real" IP address 206.125.69.81, which could be a virtual interface, through rinetd to port 80 of the address 10.1.1.2, which would typically be a machine on the inside of a firewall which has no direct routing to the outside world. Although responding on individual interfaces rather than on all interfaces is one of rinetd's primary features, sometimes it is preferable to respond on all IP addresses that belong to the server. In this situation, the special IP address 0.0.0.0 can be used. For example: 0.0.0.0 23 10.1.1.2 23 Would redirect all connections to port 23, for all IP addresses assigned to the server. This is the default behavior for most other programs. Service names can be specified instead of port numbers. On most systems, service names are defined in the file /etc/services. Both IP addresses and hostnames are accepted for bindaddress and connectaddress. ALLOW AND DENY RULES
Configuration files can also contain allow and deny rules. Allow rules which appear before the first forwarding rule are applied globally: if at least one global allow rule exists, and the address of a new connection does not satisfy at least one of the global allow rules, that connection is immediately rejected, regardless of any other rules. Allow rules which appear after a specific forwarding rule apply to that forwarding rule only. If at least one allow rule exists for a partic- ular forwarding rule, and the address of a new connection does not satisfy at least one of the allow rules for that forwarding rule, that connection is immediately rejected, regardless of any other rules. Deny rules which appear before the first forwarding rule are applied globally: if the address of a new connection satisfies any of the global allow rules, that connection is immediately rejected, regardless of any other rules. Deny rules which appear after a specific forwarding rule apply to that forwarding rule only. If the address of a new connection satisfies any of the deny rules for that forwarding rule, that connection is immediately rejected, regardless of any other rules. The format of an allow rule is as follows: allow pattern Patterns can contain the following characters: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, . (period), ?, and *. The ? wildcard matches any one character. The * wildcard matches any number of characters, including zero. For example: allow 206.125.69.* This allow rule matches all IP addresses in the 206.125.69 class C domain. Host names are NOT permitted in allow and deny rules. The performance cost of looking up IP addresses to find their corresponding names is prohibitive. Since rinetd is a single process server, all other connections would be forced to pause during the address lookup. LOGGING
rinetd is able to produce a log file in either of two formats: tab-delimited and web server-style "common log format." By default, rinetd does not produce a log file. To activate logging, add the following line to the configuration file: logfile log-file-location Example: logfile /var/log/rinetd.log By default, rinetd logs in a simple tab-delimited format containing the following information: Date and time Client address Listening host Listening port Forwarded-to host Forwarded-to port Bytes received from client Bytes sent to client Result message To activate web server-style "common log format" logging, add the following line to the configuration file: logcommon COMMAND LINE OPTIONS
The -c command line option is used to specify an alternate configuration file. The -f command line option is used to run rinetd in the foreground, without forking to the background. The -h command line option produces a short help message. The -v command line option displays the version number. REINITIALIZING RINETD
The kill -1 signal (SIGHUP) can be used to cause rinetd to reload its configuration file without interrupting existing connections. Under Linuxtm the process id is saved in the file /var/run/rinetd.pid to facilitate the kill -HUP. An alternate filename can be provided by using the <code>pidlogfile</code> configuration file option. LIMITATIONS
rinetd redirects TCP connections only. There is no support for UDP. rinetd only redirects protocols which use a single TCP socket. This rules out FTP. BUGS
The server redirected to is not able to identify the host the client really came from. This cannot be corrected; however, the log produced by rinetd provides a way to obtain this information. Under Unix, Sockets would theoretically lose data when closed with SO_LINGER turned off, but in Linux this is not the case (kernel source comments support this belief on my part). On non-Linux Unix platforms, alternate code which uses a different trick to work around blocking close() is provided, but this code is untested. The logging is inadequate. The duration of each connection should be logged. LICENSE
Copyright (c) 1997, 1998, 1999, Thomas Boutell and Boutell.Com, Inc. This software is released for free use under the terms of the GNU Pub- lic License, version 2 or higher. NO WARRANTY IS EXPRESSED OR IMPLIED. USE THIS SOFTWARE AT YOUR OWN RISK. CONTACT INFORMATION
See http://www.boutell.com/rinetd/ for the latest release. Thomas Boutell can be reached by email: boutell@boutell.com THANKS
Thanks are due to Bill Davidsen, Libor Pechachek, Sascha Ziemann, the Apache Group, and many others who have contributed advice and/or source code to this and other free software projects. LINUX
February 18, 1999 LINUX
All times are GMT -4. The time now is 03:10 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy