Hi nezabudka,
Thanks for your help, but I found 1.txt does not change to 2.txt, please help again. Many thanks.
OLD file is /tmp/path13/1.txt, NEW file is /tmp/path13/12.txt
Hi,
I would like to learn shell scripting in UNIX. Can any one please give me the support and share the information/documents with me.
If any documents please post it to aswanikumar_nimmagadda@yahoo.co.in
Thanks in advance...!!! (3 Replies)
Hi Experts,
Here is what I am trying to do.
1) say I have a file with below strings
database1
database2
database3
data10gdb1
data10gdb2
databasewithoutdigit
2) I want to get the below output.
(- if there is any digit at the end of the string, I need to remove it)
(- Any... (3 Replies)
Hi all,
i have such string stored in a variable
var1 = 00000120
i want the o/p
var1 = 120
is it possible to have such o/p in ksh/bash ...
thanx in advance for the help
sonu (3 Replies)
Hi
I am new to world on unix scripting so any assistance would be gratefully appreciated,
I am trying to write a script which reads through a file, reads in line by line, searches for a pattern, copies string after it and then to do a search and replace elsehwere in the line,
so the... (7 Replies)
Hi there, im sure this is really simple but i have some strings like this
e1000g123001
e1000g0
nge11101
nge3and i want to create two variables ($DRIVER and $INSTANCE). the first one containing the alpha characters that make up the first part of the string, e.g. e1000g or nge and the... (9 Replies)
Hi,
How to add trailer record at the end of the flat file in the unix ksh shell scripting
can you please let me know the procedure
Regards
Srikanth (3 Replies)
Hi
I have a very large data file with several hundred columns and millions of lines.
The important data is in the last set of columns with variable numbers of tab delimited fields in front of it on each line.
Im currently trying sed to get the data out - I want anything beetween :RES and... (4 Replies)
My input is as below :
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/rebate/IFIND.REBTE.WROC.txt
/splunk/scrubbed/loyal/IFIND.HELLO.WROC.txt
/splunk/scrubbed/triumph/ifind.triumph.txt
From the above input I want to extract the file names only .
Basically I want to... (5 Replies)
Hello,
I have a log file with logs such as
01/05/2017 10:23:41 : file.log.38: database error, MODE=SINGLE, LEVEL=critical, STATE: 01170255 (mode main
how can i use perl to extract the 8-digit number below from the string
01170255
Thanks (7 Replies)
Discussion started by: james2009
7 Replies
LEARN ABOUT PHP
scandir
SCANDIR(3) 1 SCANDIR(3)scandir - List files and directories inside the specified pathSYNOPSIS
array scandir (string $directory, [int $sorting_order = SCANDIR_SORT_ASCENDING], [resource $context])
DESCRIPTION
Returns an array of files and directories from the $directory.
PARAMETERS
o $directory
- The directory that will be scanned.
o $sorting_order
- By default, the sorted order is alphabetical in ascending order. If the optional $sorting_order is set to SCANDIR_SORT_DESCEND-
ING, then the sort order is alphabetical in descending order. If it is set to SCANDIR_SORT_NONE then the result is unsorted.
o $context
- For a description of the $context parameter, refer to the streams section of the manual.
RETURN VALUES
Returns an array of filenames on success, or FALSE on failure. If $directory is not a directory, then boolean FALSE is returned, and an
error of level E_WARNING is generated.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | $sorting_orderconstants were added. Any nonzero |
| | value caused descending order in previous ver- |
| | sions. So for all PHP versions, use 0 for ascend- |
| | ing order, and 1 for descending order. An option |
| | for SCANDIR_SORT_NONE behavior did not exist |
| | prior to PHP 5.4.0. |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
A simple scandir(3) example
<?php
$dir = '/tmp';
$files1 = scandir($dir);
$files2 = scandir($dir, 1);
print_r($files1);
print_r($files2);
?>
The above example will output something similar to:
Array
(
[0] => .
[1] => ..
[2] => bar.php
[3] => foo.txt
[4] => somedir
)
Array
(
[0] => somedir
[1] => foo.txt
[2] => bar.php
[3] => ..
[4] => .
)
Example #2
PHP 4 alternatives to scandir(3)
<?php
$dir = "/tmp";
$dh = opendir($dir);
while (false !== ($filename = readdir($dh))) {
$files[] = $filename;
}
sort($files);
print_r($files);
rsort($files);
print_r($files);
?>
The above example will output something similar to:
Array
(
[0] => .
[1] => ..
[2] => bar.php
[3] => foo.txt
[4] => somedir
)
Array
(
[0] => somedir
[1] => foo.txt
[2] => bar.php
[3] => ..
[4] => .
)
NOTES
Tip
A URL can be used as a filename with this function if the fopen wrappers have been enabled. See fopen(3) for more details on how to
specify the filename. See the "Supported Protocols and Wrappers" for links to information about what abilities the various wrappers
have, notes on their usage, and information on any predefined variables they may provide.
SEE ALSO opendir(3), readdir(3), glob(3), is_dir(3), sort(3).
PHP Documentation Group SCANDIR(3)