Sponsored Content
Full Discussion: query related to grep
Top Forums UNIX for Dummies Questions & Answers query related to grep Post 302548340 by newbielgn on Thursday 18th of August 2011 07:12:47 AM
Old 08-18-2011
Yes each line matching "cert_codes" will be stored in aa.txt.
But multi lines will not be grepped .Check example given below, here even though it's a multi line where 'robert' appears only robert was grepped and 'bob' missed out.

Is this what you were looking for ?

$> cat test.sh
ary=("robert" \
" bob")
for a in ${ary[@]}
do
echo $a
done

$> grep robert test.sh
ary=("robert" \
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Query related to #!/bin/sh

hi All Why is #!/bin/sh being used in most of the ksh scripts......? I have seen this (#!/bin/sh) being used at the start of the script Regards Suresh (2 Replies)
Discussion started by: sureshg_sampat
2 Replies

2. Shell Programming and Scripting

sed related query

Hi I have a file which looks like this //string = "abcd"; //info //string = "*pqrs"; //add string = "#123"; //sub //string = "#1234567890" data = check(string) //string = "#1234567890" I want to modify this as string = "#987"; //mult data = check(string) How do i do that? (1 Reply)
Discussion started by: gopsman
1 Replies

3. Shell Programming and Scripting

shell script related query

Hi I have an input to a file. I want the script to return it formatted the input is a number, say , 1234567895 and the output should be 21 43 65 87 59 ,ie, the pair of two digits should be reversed. How can I do this using a shell script? (1 Reply)
Discussion started by: gopsman
1 Replies

4. UNIX for Dummies Questions & Answers

awk related query

hi, I have to extract a column from a file and then updated that column..?? Now i can use wak for extracting it and then how to update it.. $ awk' {print $5}' input_file Can i use sed command here piping it to the output from the awk command.. (2 Replies)
Discussion started by: abhisek.says
2 Replies

5. Shell Programming and Scripting

Excel related query for the code..need help..

find /A/B/C/{1,3,5,7} -name "*.txt" -o -name "*.csv" -o -name "*.TXT" -o -name "*.dat" |xargs ls -ltr |awk '{print $8 ,$9}' > result.xls it will give the result that is $8 and &9 in the result file... let say i need the result is a excel file....and i need the result to be print like $8 field... (10 Replies)
Discussion started by: sapan123
10 Replies

6. Shell Programming and Scripting

Print related query

i Am using the below query and printing the $8 and $9 filed.. find /A/B/C/{1,3,5,7} -name "*.txt" -o -name "*.csv" -o -name "*.TXT" -o -name "*.dat" |xargs ls -ltr |awk '{print $8 ,$9}' > result.xls this give me the rsult like below.. 2008/home/ADMIN/om/1.txt 2008/home/ADMIN/om/hi.txt ... (1 Reply)
Discussion started by: sapan123
1 Replies

7. Shell Programming and Scripting

query related to if

wht does below statement mean? if wht does dis -d option do?? TIA. (1 Reply)
Discussion started by: sainathdeg
1 Replies

8. Shell Programming and Scripting

datetimestamp related query!

Hi all, I have put a query in a thread but didn't get any reply. Hoping to get a reply here. I have a file in that one line resembles like below... Forwarded by Deepak on 11/15/2009 10:28 AM EST ofcourse AM can be PM also... so what i need is first i need to get only... (1 Reply)
Discussion started by: smarty86
1 Replies

9. UNIX for Dummies Questions & Answers

A query related to 'ls' command

I am executing the ls command to show the contents of a folder, it shows some number in front of word total as highlighted in blue color below quotes. Can anyone please share that what it is? (2 Replies)
Discussion started by: Zaib
2 Replies

10. Emergency UNIX and Linux Support

Interfaces related query

I need to list the interfaces that uses FTP instead of SFTP on my applications that are on AIX servers. How do I get that list of IP addresses that connect to my applications via FTP? (2 Replies)
Discussion started by: ggayathri
2 Replies
SOCKET_CREATE_PAIR(3)							 1						     SOCKET_CREATE_PAIR(3)

socket_create_pair - Creates a pair of indistinguishable sockets and stores them in an array

SYNOPSIS
bool socket_create_pair (int $domain, int $type, int $protocol, array &$fd) DESCRIPTION
socket_create_pair(3) creates two connected and indistinguishable sockets, and stores them in $fd. This function is commonly used in IPC (InterProcess Communication). PARAMETERS
o $domain - The $domain parameter specifies the protocol family to be used by the socket. See socket_create(3) for the full list. o $type - The $type parameter selects the type of communication to be used by the socket. See socket_create(3) for the full list. o $protocol - The $protocol parameter sets the specific protocol within the specified $domain to be used when communicating on the returned socket. The proper value can be retrieved by name by using getprotobyname(3). If the desired protocol is TCP, or UDP the corre- sponding constants SOL_TCP, and SOL_UDP can also be used. See socket_create(3) for the full list of supported protocols. o $fd - Reference to an array in which the two socket resources will be inserted. RETURN VALUES
Returns TRUE on success or FALSE on failure. CHANGELOG
+--------+---------------------------------------------------+ |Version | | | | | | | Description | | | | +--------+---------------------------------------------------+ | 5.3.0 | | | | | | | This function is now re-enabled on Windows plat- | | | forms. | | | | | 4.3.0 | | | | | | | This function was due to a bug made unavailable | | | on Windows platforms. | | | | +--------+---------------------------------------------------+ EXAMPLES
Example #1 socket_create_pair(3) example <?php $sockets = array(); /* On Windows we need to use AF_INET */ $domain = (strtoupper(substr(PHP_OS, 0, 3)) == 'WIN' ? AF_INET : AF_UNIX); /* Setup socket pair */ if (socket_create_pair($domain, SOCK_STREAM, 0, $sockets) === false) { echo "socket_create_pair failed. Reason: ".socket_strerror(socket_last_error()); } /* Send and Recieve Data */ if (socket_write($sockets[0], "ABCdef123 ", strlen("ABCdef123 ")) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($sockets[0])); } if (($data = socket_read($sockets[1], strlen("ABCdef123 "), PHP_BINARY_READ)) === false) { echo "socket_read() failed. Reason: ".socket_strerror(socket_last_error($sockets[1])); } var_dump($data); /* Close sockets */ socket_close($sockets[0]); socket_close($sockets[1]); ?> Example #2 socket_create_pair(3) IPC example <?php $ary = array(); $strone = 'Message From Parent.'; $strtwo = 'Message From Child.'; if (socket_create_pair(AF_UNIX, SOCK_STREAM, 0, $ary) === false) { echo "socket_create_pair() failed. Reason: ".socket_strerror(socket_last_error()); } $pid = pcntl_fork(); if ($pid == -1) { echo 'Could not fork Process.'; } elseif ($pid) { /*parent*/ socket_close($ary[0]); if (socket_write($ary[1], $strone, strlen($strone)) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($ary[1])); } if (socket_read($ary[1], strlen($strtwo), PHP_BINARY_READ) == $strtwo) { echo "Recieved $strtwo "; } socket_close($ary[1]); } else { /*child*/ socket_close($ary[1]); if (socket_write($ary[0], $strtwo, strlen($strtwo)) === false) { echo "socket_write() failed. Reason: ".socket_strerror(socket_last_error($ary[0])); } if (socket_read($ary[0], strlen($strone), PHP_BINARY_READ) == $strone) { echo "Recieved $strone "; } socket_close($ary[0]); } ?> SEE ALSO
socket_create(3), socket_create_listen(3), socket_bind(3), socket_listen(3), socket_last_error(3), socket_strerror(3). PHP Documentation Group SOCKET_CREATE_PAIR(3)
All times are GMT -4. The time now is 08:12 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy