bash sort numerically correct [closed] - bash

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 5 years ago.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I'm having a problem with sorting that -V isn't solving. I have a very well structured set of folder names (shown below with sort -V) that I want to do a version sort but recognizing floating point numbers (see the first two entries). Any advice?
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_3_um_V_97.4_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_3_um_V_97_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_6_um_V_90_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_6_um_V_153_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_7_um_V_70_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_8_um_V_70_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_8_um_V_80_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_9_um_V_192_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_10_um_V_90_V

You can apply numeric sort for 15th field if you want to sort by floating point number.
$ cat test.txt | sort -t _ -V -k 1,14 -k 15n
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_3_um_V_97_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_3_um_V_97.4_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_6_um_V_90_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_6_um_V_153_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_7_um_V_70_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_8_um_V_70_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_8_um_V_80_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_9_um_V_192_V
Xe_phi_3.5_eV_tOn_0.5_ns_tOff_20_ns_d_10_um_V_90_V

Related

indesign cs5 numbered lists not sequencing [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 1 year ago.
Improve this question
I am trying to create a paragraph style for number lists. Pretty basic, just some customized indents etc. But each item in my list is not sequentially numbered, i.e., each item starts with 1.
Please advise.
Have you looked at "Numbering style" option ?
In my french version, "Suite…" means increment previous number. And "Commencer…" means "Starts at…"

what are the fields of the 'ls -l' call under bash [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 8 years ago.
Improve this question
What are the fields in listed order when one makes the call: ls -l in a bash shell. First I know is file type and permissions, next are a series of 4 integers that I do not know or am uncertain about, then is a date permissions were assigned then another integer and a time, then finally the file name. What I really want to know is what are the 4 integers between file permissions and permission assignment dates? The assignment dates follow a format of, ie "Oct 2 03:15"?
Considering the four integers you mention:
Hard Link Count. See this site.
Group of the user that
owns the file. Shouldn't be a number. If you get a number on your
system this would be a non-standard.
User that owns the file. Again, shouldn't be a number.
File size

Bash - removing characters other than specific string [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Improve this question
I use wget -O to get the site text to a specific file.
It saves the file within ONE line. File has about 2 milion characters. After, I would like to remove any other characters different from "directory= ************" format (including quotation mark, **** stand for any text till second quotation mark).
Is there any smart way to acomplish that?
grep -o '"directory= [^"]*"' file
The smartest way would be to pipe it out to a smarter interpreter. Python for instance.
Python has a great regular expressions library at your disposal.

How to find files with duplicated content in given a directory? SHELL [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I need to find files with the same (duplicated) content inside them in a given directory. And I need to use shell code.
Try this: BASH
find -type f -exec md5sum '{}' ';' | sort | uniq --all-repeated=separate -w 33 | cut -c 35-
Explanation:
Find all files, calculate their MD5SUM, find duplicates by comparing the MD5SUM, print the names

changing the output filenames in [split] [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Closed 9 years ago.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Improve this question
I would like to split a huge text file into separate text files. I use:
split -l 1000 file.txt split_file
and I will get split_fileaa, split_filebb, etc.
How can I change the extension to be
split_file0.txt, split_file1.txt, etc?
--additional-suffix is what you need for the additional suffix :
split -l 1000 -d --additional-suffix=.txt file.txt split_file
There is a -d option for numeric suffixes.

Resources