Username:   Password:  

Order MySQL result by occurence of a field

SELECT
 `row`,
 COUNT(row) AS `count`,
FROM
 `table`
GROUP BY
 `row`
ORDER BY
 `count`;
 
 

Sometimes it is necessary, to sort the rows of a MySQL select statement by the occurence of a field value.

Tags

MySQL count database select order occurences

Count lines of a file

/// <summary>
/// Counts the lines of a File.
/// </summary>
/// <param name="fileToCount">The file to count.</param>
/// <returns>lines of a File</returns>
private static int CountLines(string fileToCount)
{
    int counter = 0;
    using (StreamReader countReader = new StreamReader(fileToCount))
    {
        while (countReader.ReadLine() != null)
            counter++;
    }
    return counter;
}
 

Tags

C# CSharp .NET count lines files

Count lines recusively

wc -l `find . -name "*.php" -print` | tail -1 | awk '{print $1}'

Searches for all .php files in the current directory and all subdirectories and outputs the total amount of lines.

Tags

PHP count lines shell