Hi all,
I have file with following content
...........................
..........TEST..........
..........TEST..........
.....................
.....TEST..........
.....................
.....................
.....TEST..........
I want to replace nth "TEST" with "OK" using... (4 Replies)
Hello forum,
I need help with a script for displaying the number of instances/times a particular line appears in a tab-delimited file and append that number to the end of the line.
Example text file:
aaa bbb ccc ddd
ggg hhh kkk nnn
aaa bbb ccc ddd
aaa bbb ccc ddd
ppp qqq nnn sss
ggg... (1 Reply)
I have a record like the one given below.
010000306551~IN ~N~ |WINDWARD PK|Alpharetta|
If ~ is present more than instance in a line,then I need to delete those instances.
Any ideas?
I am working in Solaris (7 Replies)
I was told a way to do this with awk earlier today but is there a way with sed to specify the last instance of a character on a line?
You will know what character you're looking for but there could be none or one hundred instances of it on a line say and you ONLY want to specify the last one for... (3 Replies)
test.txt is the dynamic file but some of combination are fix
like below are the lines
;wonder_off =
;wonder_off = disabled
wonder_off =
wonder_off = disabled
the test.txt can content them in any order
#cat test.xt
;wonder_off =
;wonder_off = disabled
wonder_off =
wonder_off =... (5 Replies)
Suppose you have a line like this:
cn=user.blr.ou=blr.india.o=company
The line should be converted like this:
cn=user.blr,ou=blr.india,o=comapny
Was wondering how to do that using shell script.
Please use tags where appropriate, thank you (4 Replies)
I Have a text file with several thousand lines of text.
Occasionally there will be a "sysAlive" line of text (every so often)
What would be an awk command to print every line of text, and to put in incrementing counter ONLY on the "sysAlive" lines
For example:
>cat file.txt
lineAAA a b c d... (4 Replies)
Hi,
Need help on replacing every second instance of delimeter.
Scenario:
var="Name1,Value1,Name2,Value2,Name3,Value3,Name4,Value"
I want every second "," to replace with "|"
I tried like below
echo $var| sed 's/,/|/2'
But, it's not working.
Expected output:
... (4 Replies)
Discussion started by: Sumanthsv
4 Replies
LEARN ABOUT PHP
stream_wrapper_register
STREAM_WRAPPER_REGISTER(3) 1 STREAM_WRAPPER_REGISTER(3)stream_wrapper_register - Register a URL wrapper implemented as a PHP classSYNOPSIS
bool stream_wrapper_register (string $protocol, string $classname, [int $flags])
DESCRIPTION
Allows you to implement your own protocol handlers and streams for use with all the other filesystem functions (such as fopen(3), fread(3)
etc.).
PARAMETERS
o $protocol
- The wrapper name to be registered.
o $classname
- The classname which implements the $protocol.
o $flags
- Should be set to STREAM_IS_URL if $protocol is a URL protocol. Default is 0, local stream.
RETURN VALUES
Returns TRUE on success or FALSE on failure.
stream_wrapper_register(3) will return FALSE if the $protocol already has a handler.
CHANGELOG
+--------+------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+------------------------------+
| 5.2.4 | |
| | |
| | Added the $flags parameter. |
| | |
+--------+------------------------------+
EXAMPLES
Example #1
How to register a stream wrapper
<?php
$existed = in_array("var", stream_get_wrappers());
if ($existed) {
stream_wrapper_unregister("var");
}
stream_wrapper_register("var", "VariableStream");
$myvar = "";
$fp = fopen("var://myvar", "r+");
fwrite($fp, "line1
");
fwrite($fp, "line2
");
fwrite($fp, "line3
");
rewind($fp);
while (!feof($fp)) {
echo fgets($fp);
}
fclose($fp);
var_dump($myvar);
if ($existed) {
stream_wrapper_restore("var");
}
?>
The above example will output:
line1
line2
line3
string(18) "line1
line2
line3
"
SEE ALSO
The "streamWrapper" prototype class, "Example class registered as stream wrapper", stream_wrapper_unregister(3), stream_wrapper_restore(3),
stream_get_wrappers(3).
PHP Documentation Group STREAM_WRAPPER_REGISTER(3)