If you were to nominate the most frequent โchoreโ you set your โsoftware programsโ to do, and we should never forget we are here to make software that achieves something, there is a big chance youโd choose the job of sorting data. The why I guess relates to how a lot of we humans want data presented โฆ we seek order โฆ and are generally a bit afraid of chaos โฆ whether this is good always is for 56784532 other conversations to have.
Letโs go back to a thinking close to the operating system of interest โฆ and today that is Linux โฆ and look at some command line Linux that will work on most/all Linux or Unix operating systems โฆ it is pretty fundamental stuff.
The base command of interest may amaze you โฆ are you ready โฆ
sort [inputFile]
โฆ gasp โฆ but sort just like that assumes some of the defaults (depending on your deep configuration settings (ie. in your profile, with an alias, you can change them)) โฆ
- alphabetical sorting
- total record sorting (as if all the characters on a carriage return/line feed delimited string)
- ascending sort (from least to greatest)
- the sort determination looks from the leftmost character and proceeds to the right
โฆ but, today, with our piped sort commands we present switches that can change the first three defaults, respectively โฆ
- -n
- -k [colNumber] -t[delimiterCharacter]
- -r
โฆ in other words โฆ
- numerical sort
- sort by field [colNumber] where fields are separated by [delimiterCharacter]
- descending sort
We also touch on other commands with our look at Linux sorting of our input CSV data that we talked about with PHP/Javascript/HTML Google Chart JSON Data Table Import of CSV Tutorial as shown below that has fields โCountryโ,โPopulationโ,โCrude Birth Rateโ โฆ
- cat [CSVfileName] โฆ type a file called [CSVfileName]
- uniq โฆ pipe to enforce record uniqueness
- sort -u โฆ pipe and switch to enforce field (of record) uniqueness
- grep โ[searchCriteria]โ โฆ piped filter to include only records satisfying [searchCriteria]
- sed โ/$/s//,5/gโ โฆ piped record modifier adding a new column (ie. ,5) to right of our input CSV data
Hope you find some interest in this Linux operating system command discussion. This is raw command line talk but it can also be supervised as a useful component tool by, (amongst other ideas by) โฆ
- web server side language supervision โฆ eg. via PHP exec for example, or via curl (of that PHP)
- called by compiled desktop program, such as Java, C++, C
- called by a Linux/Unix shell script โฆ in Bourne Shell, Korn Shell, C Shell, tcsh, Unix Shell
Previous relevant data from PHP/Javascript/HTML Google Chart JSON Data Table Import of CSV Tutorial is shown below.
Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its JSON Data Table functionality.
Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.
Thanks to the World Bank for some statistics which helped a lot.
Letโs see some PHP code in live action for this tutorial where you see a JSON Data Table derived from a filename passed as a parameter in the URL. The data shown is based on a CSV file of a previous PHP/Javascript/HTML Google Chart Intensity Map Tutorial shown below.
Link to Google Chart Tools โspiritual homeโ โฆ via Google.
Link to Google Chart Tools JSON Data Table information โฆ via Google.
Link to some downloadable PHP programming code โฆ rename to chart_editor_inphp.
Link to some downloadable PHP programming code โฆ rename to json_data_tablephp.
Link to some downloadable input CSV data โฆ rename to Google_Chart_Intensity_Chart_Tutorial_asCSV.
Previous PHP/Javascript/HTML Google Chart Intensity Map Tutorial below โฆ
Here is a tutorial that introduces you to Google Graphs API, or Google Chart Tools, and its Intensity Map functionality.
Google Chart Tools provide a perfect way to visualize data on your website. From simple line charts to complex hierarchical tree maps, the chart galley provides a large number of well-designed chart types. Populating your data is easy using the provided client- and server-side tools.
Thanks to the World Bank for some statistics which helped a lot.
Letโs see some PHP code in live action for this tutorial where you define your intensity map characteristics and data.
Now part of an Android App called Geo Chart++ in July 2013.
Link to Google Chart Tools โspiritual homeโ โฆ via Google.
Link to Google Chart Tools Intensity Map information โฆ via Google.
Link to some downloadable PHP programming code โฆ rename to intensity_chartphp.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
If this was interesting you may be interested in this too.
13 Responses to Linux sort Tutorial