Hi,
I need to insert a line into a file underneath an existing line in the file, but am unsure as to the syntax. I'm pretty sure sed can be used though, although any ideas are more than welcome. For example:
File
----
Line 1
Line 2
Line 3
Line 4
Line 6
I need to say: Insert "Line 5"... (1 Reply)
Could someone tell me how to replace varibles using SED inside Korn Shell?
e.g. I have a ksh file program.ksh below:
------------------------------------
#!/bin/ksh
sed -n '/ABC/p' $1 > output.txt
if ]
then
status=new
elif ]
then
status=old
fi
sed -n '/$status/p' $1... (5 Replies)
Hi All,
i have one file and in that i have to read each line and do some replacement.
its is not fixed the number or column always be same it can be less also
exm
a;b;c;d;e;f (line)
i have to do something like
In the line
If c is present
then
go to end of line and append ';date'
else... (9 Replies)
Hi,
I have a file in a form of
jkkhjjk1:!:jkhdjkhjkh2:!:kljkljkljklj3:!:kljsdj4
kljlkfljf5:!:kjljljlj6:!:jhjkhjkh7
I am trying to use sed command such that everytime it find ":!:" it will removes it and print remaining of the line on the new line
Output that I need will look like following... (8 Replies)
Hi,
I have the following texts :
#1#http://www.google.com#2#Google#3#
#1#http://www.aol.com#2#AOL#3#
I need a bash script which extracts the text between the markers (marks are #1#,#2#,#3#).
I also need that text in variables ($URL and $DESCRIPT will be fine) so I can later use it to... (3 Replies)
I am trying to retrieve part of a line from /boot/grub/menu.lst
The line is :
gfxmenu (hd0,0)/usr/share/gfxboot/themes/pclinuxblue/boot/message
I have figured out how to get this line into a file by itself.
sed '/gfxmenu/ !d' /boot/grub/menu.lst > /tmp/menu.lst.pcl_tc
What I need to... (2 Replies)
Hi All ,
I have a input file which has set of lines like this ::
cat a.txt
unix1 djkdfkjdkkdfkdjfdfkjd 09191091 unix@unix.com <2008-23-07>
unix 2 dfdfdfdfdfdfdfdfdfd
unix3 dfldfljdflkjdfldfkljdfldjfl 0565606 unix1@unix.com <2008-10-09>
unix4 dfdlfndfldflnlffddfd
for some... (4 Replies)
Hi,
I would like to process one file which looks like this :
09-04-16-17:11:53 -> count 1
NAME CHAN QID NMSGS NBYTES MAXBYTES P/T
W_DEALNUM 105 123508770 1 10 14 P
W_APPSTAT 106 123508771 1 12 35 P... (8 Replies)
Hello!
I have a "problem" with sed... In a log, I'm wondering how to have the name of the application when "INCIDENT" is in the file...
The name of the application is before "INCIDENT".
For this example, The result should be "SPVP0005"
thanks for your help! (7 Replies)
I want to search texts between first occurence of the matching pattern and replace it with some other text.pls advice what can be done. I searched alot, i could not find anything relevant.
Ex my input is as follows:
red
yellow
grey
white
blue
red
pink
violet
white
I want to search... (9 Replies)
Discussion started by: sangitajc
9 Replies
LEARN ABOUT PHP
socket_bind
SOCKET_BIND(3) 1 SOCKET_BIND(3)socket_bind - Binds a name to a socketSYNOPSIS
bool socket_bind (resource $socket, string $address, [int $port])
DESCRIPTION
Binds the name given in $address to the socket described by $socket. This has to be done before a connection is be established using
socket_connect(3) or socket_listen(3).
PARAMETERS
o $socket
- A valid socket resource created with socket_create(3).
o $address
- If the socket is of the AF_INET family, the $address is an IP in dotted-quad notation (e.g. 127.0.0.1). If the socket is of
the AF_UNIX family, the $address is the path of a Unix-domain socket (e.g. /tmp/my.sock).
o $port (Optional)
- The $port parameter is only used when binding an AF_INET socket, and designates the port on which to listen for connections.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
The error code can be retrieved with socket_last_error(3). This code may be passed to socket_strerror(3) to get a textual explanation of
the error.
EXAMPLES
Example #1
Using socket_bind(3) to set the source address
<?php
// Create a new socket
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
// An example list of IP addresses owned by the computer
$sourceips['kevin'] = '127.0.0.1';
$sourceips['madcoder'] = '127.0.0.2';
// Bind the source address
socket_bind($sock, $sourceips['madcoder']);
// Connect to destination address
socket_connect($sock, '127.0.0.1', 80);
// Write
$request = 'GET / HTTP/1.1' . "
" .
'Host: example.com' . "
";
socket_write($sock, $request);
// Close
socket_close($sock);
?>
NOTES
Note
This function must be used on the socket before socket_connect(3).
Note
Windows 9x/ME compatibility note: socket_last_error(3) may return an invalid error code if trying to bind the socket to a wrong
address that does not belong to your machine.
SEE ALSO socket_connect(3), socket_listen(3), socket_create(3), socket_last_error(3), socket_strerror(3).
PHP Documentation Group SOCKET_BIND(3)