10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
for fd in $(grep "/tmp/" hello.properties)The grep gives me the below output:
deploydir=/tmp/app1/dfol
prodir= /tmp/hello/prop
......
Now i want to store /tmp/app1/dfol then /tmp/hello/prop in a variable so that i can check if those folders files exists or not.
The delimiter would... (4 Replies)
Discussion started by: mohtashims
4 Replies
2. Shell Programming and Scripting
I want a string between two delimeter like ( ) from file.
Input File,
2007_08_07_IA-0100-014_(January).PDF
2007_08_07_IA-0100-031_(January February March
April June July).PDF
2008-02-28_KR-1022-003_(January
febuary
march
april
may).CSV
Output File,
January
January February... (19 Replies)
Discussion started by: Pratik Majithia
19 Replies
3. Shell Programming and Scripting
Hi ,
I have a set of files in a folder which i need to cut in to two parts....
Sample files
touch AE_JUNFOR_2014_MTD_2013-05-30-03-30-02.TXT
touch AE_JUNFOR_2014_YTD_2013-05-30-03-30-02.TXT
touch temp_AE_JUNFOR_2014_MTD_2013-05-30-03-30-02.TXT
touch... (4 Replies)
Discussion started by: chillblue
4 Replies
4. Shell Programming and Scripting
hi all,
suppose a string:
abc/def/ghi/jkl/mn.txt
and i want to get the file name without the path.
however, different files have different paths, therefore the number of delimiter is uncertain.
thanks so much! (3 Replies)
Discussion started by: sunnydanniel
3 Replies
5. Shell Programming and Scripting
#/bin/sh
sysdate=`date +"%m/%d/%Y"`
systime=`date +%r`
ps_per=`lsps -s | nawk '{print $2+0}'|tail -1`
ps_tot=`lsps -s | nawk '{print $1+0}'|tail -1`
lcpu=`vmstat | nawk -F= '/lcpu/ {print $2+0}'`
mem_tot=`vmstat | nawk -F= '/mem=/ {print $3+0}'`
avm=`vmstat|awk '{print... (7 Replies)
Discussion started by: Daniel Gate
7 Replies
6. Shell Programming and Scripting
I have the following script working fine, and need to generate a file delimiter (with tab or special character) for Excel data import. The script will run every hour in crontab to append the new rows to the delimiter, so that I can collect the data for i.e. a week, which will give me a lot of... (0 Replies)
Discussion started by: Daniel Gate
0 Replies
7. Shell Programming and Scripting
Hi;
I want to write a shell script that will split a string with no delimiter.
Basically the script will read a line from a file.
For example the line it read from the file contains:
99234523
These values are never the same but the length will always be 8.
How do i split this... (8 Replies)
Discussion started by: saint34
8 Replies
8. Shell Programming and Scripting
Hi ,
I need to get the delimiter "-" count in a particular string.
string= SYS_NAME-123-S5-2008-10-20.LOG
the delimit "-" count is 5 .
Using sed or awk can I know the count ?
I have seen how to get the count for delimiter in a file but not a string :(
Thanks,
Priya (8 Replies)
Discussion started by: priyam
8 Replies
9. Shell Programming and Scripting
Hi,
I'm wondering what is the best way to parse out a long string that has a specific deliminator and outputting each token between the delim on a newline?
i.e. input
text1,text2,text3,tex4
i.e. output
text1
text2
text3
text4 (8 Replies)
Discussion started by: primp
8 Replies
10. Shell Programming and Scripting
Hi,
I need to split a string, either using awk or cut or basic unix commands (no programming) , with a multibyte charectar as a delimeter.
Ex:
abcd-efgh-ijkl
split by -efgh- to get two segments abcd & ijkl
Is it possible?
Thanks
A.H.S (1 Reply)
Discussion started by: azmathshaikh
1 Replies
EXPLODE(3) 1 EXPLODE(3)
explode - Split a string by string
SYNOPSIS
array explode (string $delimiter, string $string, [int $limit])
DESCRIPTION
Returns an array of strings, each of which is a substring of $string formed by splitting it on boundaries formed by the string $delimiter.
PARAMETERS
o $delimiter
- The boundary string.
o $string
- The input string.
o $limit
- If $limit is set and positive, the returned array will contain a maximum of $limit elements with the last element containing the
rest of $string. If the $limit parameter is negative, all components except the last -$limit are returned. If the $limit parame-
ter is zero, then this is treated as 1.
Note
Although implode(3) can, for historical reasons, accept its parameters in either order, explode(3) cannot. You must ensure that the
$delimiter argument comes before the $string argument.
RETURN VALUES
Returns an array of strings created by splitting the $string parameter on boundaries formed by the $delimiter.
If $delimiter is an empty string (""), explode(3) will return FALSE. If $delimiter contains a value that is not contained in $string and a
negative $limit is used, then an empty array will be returned, otherwise an array containing $string will be returned.
CHANGELOG
+--------+-----------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+-----------------------------------------+
| 5.1.0 | |
| | |
| | Support for negative $limits was added |
| | |
+--------+-----------------------------------------+
EXAMPLES
Example #1
explode(3) examples
<?php
// Example 1
$pizza = "piece1 piece2 piece3 piece4 piece5 piece6";
$pieces = explode(" ", $pizza);
echo $pieces[0]; // piece1
echo $pieces[1]; // piece2
// Example 2
$data = "foo:*:1023:1000::/home/foo:/bin/sh";
list($user, $pass, $uid, $gid, $gecos, $home, $shell) = explode(":", $data);
echo $user; // foo
echo $pass; // *
?>
Example #2
explode(3) return examples
<?php
/*
A string that doesn't contain the delimiter will simply
return a one-length array of the original string.
*/
$input1 = "hello";
$input2 = "hello,there";
var_dump( explode( ',', $input1 ) );
var_dump( explode( ',', $input2 ) );
?>
The above example will output:
array(1)
(
[0] => string(5) "hello"
)
array(2)
(
[0] => string(5) "hello"
[1] => string(5) "there"
)
Example #3
$limit parameter examples
<?php
$str = 'one|two|three|four';
// positive limit
print_r(explode('|', $str, 2));
// negative limit (since PHP 5.1)
print_r(explode('|', $str, -1));
?>
The above example will output:
Array
(
[0] => one
[1] => two|three|four
)
Array
(
[0] => one
[1] => two
[2] => three
)
NOTES
Note
This function is binary-safe.
SEE ALSO
preg_split(3), str_split(3), mb_split(3), str_word_count(3), strtok(3), implode(3).
PHP Documentation Group EXPLODE(3)