I’m quite new to linux, and I can’t quite get to understand sorting. I need to sort a long file by column 4 and then column 5, ignoring the first line. The catch is, there are two separators – ‘.’ and ‘,’ – I don’t know how to make sort command to include both of them. I guess it has
Tag: sorting
Linux Sort words alphabetically and make a file for each letter
I want to write a shell script which creates automatically 26 dictionary files, where the first file should contain all the words starting with a or A, the second all the words starting with b or B, … etc. Where each dictionary file is sorted. For example, if I had a file that had the words Lime, Apple, Orange, Avacado,
want to sort my log file on this timestamp 2019-06-29T12:39:23.428Z using sort command but confused as there are multiple delimeter
This is the format of timestamp on which 2019-06-29T12:39:23.428Z I want to sort. But the year is delimited by – and the time is delimited by : and both year and time are separated my T’. Tried this. Answer You can manually pick out each field to sort with -k from man: So something like this should sort your output:
Reverse sort 3rd numeric column in file
In bash shell scripting, I have users.txt file. sort -t: -k 3n users.txt gives me This is ok. But I need 3rd column which contain only phone number in reverse order i.e. descending order. How to achieve that? I need like Answer You could add an r (short for “reverse”) to the order column specification:
File is not sort after sort
I have a problem with sorting my file. My file look like this geom-10-11.com 1 geom-1-10.com 9 geom-1-11.com 10 geom-1-2.com 1 geom-1-3.com 2 geom-1-4.com 3 geom-1-5.com 4 geom-1-6.com 5 geom-1-7.com 6 geom-1-8.com 7 geom-1-9.com 8 geom-2-10.com 8 geom-2-11.com 9 geom-2-3.com 1 geom-2-4.com 2 geom-2-5.com 3 geom-2-6.com 4 geom-2-7.com 5 geom-2-8.com 6 geom-2-9.com 7 geom-3-10.com 7 geom-3-11.com 8 geom-3-4.com 1 geom-3-5.com
python way to find unique version of software
I’ve multiple components of a software (let’s call it XYZ) installed on my linux (RHEL 6.2) server running python 3.3. I’m trying to covert my install/upgrade script from shell to python. For that I need to fetch the version number, but only once. In my python script I’ve added the below code I want to use python based commands instead
Sorting an array of dates in bash
I want to sort an array of dates. Example format: “2017-11-13_07-55-40” or Year-Month-Date_Hour-Minute-Second Answer Since your dates are already in YYYY-MM-DD-HH-MM-SS format, you can use numeric sort: To store output in another array use:
Bash sort -nu results in unexpected behaviour
A colleague of mine noticed some odd behaviour with the sort command today, and I was wondering if anyone knows if the output of this command is intentional or not? Given the file: We are looking to sort the file with numeric sort, and also make it unique, so we run: The output is: Now, we know that the numeric
Sort a find command to respect a custom order in Unix
I have a script that outputs file paths (via find), which I want to sort based on very specific custom logic: 1st sort key: I want the 2nd and, if present, the 3rd –separated field to be sorted using custom ordering based on a list of keys I supply – but excluding a numerical suffix. With the sample input below,
AWK – Show lines where column contains a specific string
I have a document (.txt) composed like that. And I want to show some information by column. For example, I have some different information in “info3” shield, I want to see only the lines who are composed by “test” in “info3” column. I think I have to use sort but I’m not sure. Any idea ? Answer You can use