Hi guys, I hope you can help me with my problem.
I have a text file that contains lines like this:
78 ANGELO -809.05
79 ANGELO2 -5,000.06
I need to find all occurences of amounts that are negative and replace them with x's
78 ANGELO xxxxxxx
79... (4 Replies)
for a certain directory, I want to grep a particular file called ABCD so what I do is
ls /my/dir | grep -i "ABCD" | awk '{print $9}'
however, there is also this file called ABCDEFG, the above command would reurn both file when I only want ABCD, please help! (3 Replies)
Hello,
i have a program where i have to get a character from the user and check it against the word i have and then replace the character in a blank at the same position it is in the word. (7 Replies)
I have a requirement of shell script where i need to read the File name i.e ls -t | head -1 and Match that Filename with some delimited values which are in a separate File.
For Example i am reading the File name i.e (ls -t | head -1) after that i need to read one more sequential file which... (2 Replies)
Little lost here, I am trying to search a line for both values after the $ signs. My ultimate goal is to get percertage.
<?php
$string = "Something on sale for $4 and orginal price $10";
$strstr =. strstr($string, '$');
$strrchr =. strrchr($string, '$');
echo "$strstr<br>";
echo... (1 Reply)
I have a string like ab or abc of whatever length. But i want to know whether another string ( for example, abcfghijkl, OR a<space> bcfghijkl ab<space> cfghijkl OR a<space>bcfghijkl OR ab<space> c<space> fghijkl ) starts with ab or abc... space might existing on the longer string... If so, i... (4 Replies)
Hi,
i want to know how to compare string of file with input string
im trying following code:
file_no=`paste -s -d "||||\n" a.txt | cut -c 1`
#it will return collection number from file
echo "enter number"
read " curr_no"
if ; then
echo " current number already present"
fi
... (4 Replies)
here is what i want to achieve... consider a file contains below contents. the file size is large about 60mb
cat dump.sql
INSERT INTO `table1` (`id`, `action`, `date`, `descrip`, `lastModified`) VALUES (1,'Change','2011-05-05 00:00:00','Account Updated','2012-02-10... (10 Replies)
Hello,
I am working with google ngram data set which is of size 100s of gb. Before using it with Java, I wanted to filter it out using shell script.
Here is a sample line in the file:
2.55 1.57 1992 10 20 30
The first two fields (2.55 and 1.57) are... (3 Replies)
Hello all,
i am trying to match a string and based on that proceed with my script or error out...
i have a file called /tmp/sta.log that will be populated by oracle's spooling..it can
have a output of either 2 of the below (OPEN or errors/ORACLE not avaiable)
$ cat /tmp/sta.log
OPEN
$
$... (2 Replies)
Discussion started by: abdul.irfan2
2 Replies
LEARN ABOUT PHP
sort
SORT(3) 1 SORT(3)sort - Sort an arraySYNOPSIS
bool sort (array &$array, [int $sort_flags = SORT_REGULAR])
DESCRIPTION
This function sorts an array. Elements will be arranged from lowest to highest when this function has completed.
PARAMETERS
o $array
- The input array.
o $sort_flags
- The optional second parameter $sort_flags may be used to modify the sorting behavior using these values: Sorting type flags:
o SORT_REGULAR - compare items normally (don't change types)
o SORT_NUMERIC - compare items numerically
o SORT_STRING - compare items as strings
o SORT_LOCALE_STRING - compare items as strings, based on the current locale. It uses the locale, which can be changed using
setlocale(3)
o SORT_NATURAL - compare items as strings using "natural ordering" like natsort(3)
o SORT_FLAG_CASE - can be combined (bitwise OR) with SORT_STRING or SORT_NATURAL to sort strings case-insensitively
RETURN VALUES
Returns TRUE on success or FALSE on failure.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.4.0 | |
| | |
| | Added support for SORT_NATURAL and |
| | SORT_FLAG_CASE as $sort_flags |
| | |
| 5.0.2 | |
| | |
| | Added SORT_LOCALE_STRING |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
sort(3) example
<?php
$fruits = array("lemon", "orange", "banana", "apple");
sort($fruits);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "
";
}
?>
The above example will output:
fruits[0] = apple
fruits[1] = banana
fruits[2] = lemon
fruits[3] = orange
The fruits have been sorted in alphabetical order.
Example #2
sort(3) example using case-insensitive natural ordering
<?php
$fruits = array(
"Orange1", "orange2", "Orange3", "orange20"
);
sort($fruits, SORT_NATURAL | SORT_FLAG_CASE);
foreach ($fruits as $key => $val) {
echo "fruits[" . $key . "] = " . $val . "
";
}
?>
The above example will output:
fruits[0] = Orange1
fruits[1] = orange2
fruits[2] = Orange3
fruits[3] = orange20
The fruits have been sorted like natcasesort(3).
NOTES
Note
This function assigns new keys to the elements in $array. It will remove any existing keys that may have been assigned, rather than
just reordering the keys.
Note
Like most PHP sorting functions, sort(3) uses an implementation of Quicksort. The pivot is chosen in the middle of the partition
resulting in an optimal time for already sorted arrays. This is however an implementation detail you shouldn't rely on.
Warning
Be careful when sorting arrays with mixed types values because sort(3) can produce unpredictable results.
SEE ALSO asort(3), The comparison of array sorting functions.
PHP Documentation Group SORT(3)