How could I check if a string variable contains at least (or only) 2 characters, and check and make sure that the string does not contain any numeric digits?...I need to know how to do this as simple as possible. and I am using the Ksh shell. Thanks. (1 Reply)
I've got a file (numbers.txt) filled with numbers and I want to replace each one of those numbers with a new random number between 0 and 9. This is my script so far:
#!/bin/bash
rand=$(($RANDOM % 9))
sed -i s//$rand/g numbers.txtThe problem that I have is that it replaces each number with just... (2 Replies)
hi
i am writing a hangman script and am having trouble checking the correct letters against the word
i need the script to compare the word against the letters guessed that are correct so once all the letters within the word have been guessed it will alow me to create a wining senario
eg
... (3 Replies)
i need to replace the any special characters with escape characters like below.
test!=123-> test\!\=123
!@#$%^&*()-= to be replaced by
\!\@\#\$\%\^\&\*\(\)\-\= (8 Replies)
sed -e "s// /g" old.txt > new.txt
While I do know some control characters need to be escaped, can normal characters also be escaped and still work the same way? Basically I do not know all control characters that have a special meaning, for example, ?, ., % have a meaning and have to be escaped... (11 Replies)
Hi, (i'm sorry for my english)
I'm a problem on boot sco unix 5.0.5 open server.
this stop at "Checking protected password and checking subsystem databases"
(See this image )
I'm try this:
1) http://www.digipedia.pl/usenet/thread/50/37093/#post37094
2) SCO: SCO Unix - Server hangs... (9 Replies)
I am having a zipped file which has the following URL contents -
98.70.217.222 - - "GET /liveupdate-aka.symantec.com/1340071490jtun_nav2k8enn09m25.m25?h=abcdefgh HTTP/1.1" 200 159229484 "-" "hBU1OhDsPXknMepDBJNScBj4BQcmUz5TwAAAAA" "-"
In this line here is we only need to consider the... (4 Replies)
Hello, I am working with some very large files (upwards of 1M records). I have written code to parse out a lot of the data and am using awk rather than a built-in "while read LINE" for performance (I have tested both ways). That said, I now need to read each of these incoming lines, check the ninth... (2 Replies)
My question is basically as the title says. How can I check a user inputted string is only certain characters long (for example, 3 characters long) and how do I check a user inputted string only contains certain characters (for example, it should only contain the characters 'u', 'a', 'g', and 'c')... (4 Replies)
I have this fastq file:
@M04961:22:000000000-B5VGJ:1:1101:9280:7106 1:N:0:86
GGGGGGGGGGGGCATGAAAACATACAAACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCA
+test-1
GGGGGGGGGGGGGGGGGCCGGGGGFF,EDFFGEDFG,@DGGCGGEGGG7DCGGGF68CGFFFGGGG@CGDGFFDFEFEFF:30CGAFFDFEFF8CAF;;8... (10 Replies)
Discussion started by: Xterra
10 Replies
LEARN ABOUT PHP
fgetcsv
FGETCSV(3) 1 FGETCSV(3)fgetcsv - Gets line from file pointer and parse for CSV fieldsSYNOPSIS
array fgetcsv (resource $handle, [int $length], [string $delimiter = ","], [string $enclosure = '"'], [string $escape = "
DESCRIPTION
Similar to fgets(3) except that fgetcsv(3) parses the line it reads for fields in CSV format and returns an array containing the fields
read.
PARAMETERS
o $handle
- A valid file pointer to a file successfully opened by fopen(3), popen(3), or fsockopen(3).
o $length
- Must be greater than the longest line (in characters) to be found in the CSV file (allowing for trailing line-end characters).
It became optional in PHP 5. Omitting this parameter (or setting it to 0 in PHP 5.1.0 and later) the maximum line length is not
limited, which is slightly slower.
o $delimiter
- The optional $delimiter parameter sets the field delimiter (one character only).
o $enclosure
- The optional $enclosure parameter sets the field enclosure character (one character only).
o $escape
- The optional $escape parameter sets the escape character (one character only).
RETURN VALUES
Returns an indexed array containing the fields read.
Note
A blank line in a CSV file will be returned as an array comprising a single null field, and will not be treated as an error.
Note
If PHP is not properly recognizing the line endings when reading files either on or created by a Macintosh computer, enabling the
auto_detect_line_endings run-time configuration option may help resolve the problem.
fgetcsv(3) returns NULL if an invalid $handle is supplied or FALSE on other errors, including end of file.
CHANGELOG
+--------+---------------------------------------------------+
|Version | |
| | |
| | Description |
| | |
+--------+---------------------------------------------------+
| 5.3.0 | |
| | |
| | The $escape parameter was added |
| | |
| 5.1.0 | |
| | |
| | The $length is now optional. Default is 0, mean- |
| | ing no length limit. |
| | |
| 4.3.5 | |
| | |
| | fgetcsv(3) is now binary safe |
| | |
+--------+---------------------------------------------------+
EXAMPLES
Example #1
Read and print the entire contents of a CSV file
<?php
$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
$num = count($data);
echo "<p> $num fields in line $row: <br /></p>
";
$row++;
for ($c=0; $c < $num; $c++) {
echo $data[$c] . "<br />
";
}
}
fclose($handle);
}
?>
NOTES
Note
Locale setting is taken into account by this function. If $LANG is e.g. en_US.UTF-8, files in one-byte encoding are read wrong by
this function.
SEE ALSO str_getcsv(3), explode(3), file(3), pack(3), fputcsv(3).
PHP Documentation Group FGETCSV(3)