Skip to main content

All Questions

Tagged with
1 vote
1 answer
103 views

Difficulty performing complex sorting when listing files in a directory with the ls command

The behavior I'm seeking is a nested sort with the ls command where sorting by one method doesn't cancel out sorting by a second method. The exact desired behavior is essentially: First sort with ...
elucid8's user avatar
  • 78
0 votes
0 answers
224 views

Extract files in order by numbers at end of filename (windows)

I want to use a Windows .bat file to extract a number of files in a folder. I have files with numbers at the end of filename, just before the extension, and I need to extract them in order of these ...
Antóin's user avatar
0 votes
1 answer
773 views

UNIX or Linux sort: only sort on the first part of an entry

I'm working on a complicated grep, something like grep -E -i "first|next" *.txt, and I get results like: logs.10.txt:2022-10-07 10:33:05.6673 | ClassName | [Info] | Inside function first(), ...
Dominique's user avatar
  • 2,283
0 votes
1 answer
2k views

How to sort text by last column?

This command udisksctl status with Ubuntu 20.04.3 gives: MODEL REVISION SERIAL DEVICE -------------------------------------------------------------------------- ...
user1539864's user avatar
34 votes
1 answer
6k views

Why does the `ls` command sort files like this?

As I was trying to reverse engineer the ls command, I came upon an interesting behavior. When I make 3 files, foo.png, foopa.png, and fooqa.png, ls sorts them as foopa.png, foo.png, and fooqa.png. I ...
mooncat39's user avatar
  • 341
0 votes
1 answer
1k views

How do I take the stdout of two commands and pipe them as two args into sort?

I can do the following: sort -nbms file1.txt file2.txt and it will merge the two already sorted files. What I wish to do is take the output from two commands (its sorted) and pipe it in as input ...
Cheetah's user avatar
  • 1,263
0 votes
1 answer
151 views

Linux version sort; letters first

GNU sort -V is great for sorting IP adresses. Unfortunately it throws all lines with leading letters (as opposed to numbers) to the bottom of the pile. Is there a way around it? Note: • 192.168.0.103 ...
voices's user avatar
  • 2,751
0 votes
1 answer
1k views

Sort all files in a folder independently, with an output file for each

I have several folders that contain numerous text files, ranging from tens to 100s. These text files are simple databases containing millions of lines, with each line containing a single record. ...
Hashim Aziz's user avatar
  • 13.1k
3 votes
1 answer
973 views

Sort with case-sensitivity in macOS in the Terminal

I am trying to use the answer in GNU Sort by case-sensitive to sort a file in my Mac OS. My file.txt looks like this: "Best" "A" "BEST" In the second answer to the mentioned question, it says that ...
regina_fallangi's user avatar
1 vote
1 answer
5k views

Windows CLI: sort text file by column

I'd like to sort a text file by the 3rd column of data, not the 3rd character, using pure Windows CLI commands. The commands would be put into a batch file. The data would look something like #...
masher's user avatar
  • 211
4 votes
2 answers
592 views

Sort packs of lines alphabetically

Note: the complementary question is here: How to separately sort lines within multiple “chunks” separated with headers? So what I did find an answer to, is how to sort lines in a text files ...
Paul Giroud's user avatar
1 vote
0 answers
1k views

How to get files ordered by name with `dir`?

This used to be really easy in the old OS's. dir /o:n >> list.txt for %a in (`list.txt`) do copy %a ..\ordered And voila, there was the list of files in the other folder, created in the sorted ...
Alex's user avatar
  • 208
1 vote
1 answer
2k views

Linux Shell - Sort a text file by the length of each line, then print the shortest line

I have a file, file.txt, that contains the following: This is many letters This is few Hi This is a very long sentence. (It actually is a few thousand lines long, but I am new to Linux, and want to ...
Avery Kucan's user avatar
1 vote
4 answers
2k views

UNIX Command to sort file based on word delimited

I have a file that has lines file.txt like this: www.site.com/230207|Sophie Rundle title: Episodes|5irko3ke www.site.com/228264|Camilla Luddington title: Balifornication|5423234 www.site.com/...
Online User's user avatar
0 votes
1 answer
189 views

open files in sorted order (OSX)

I'm looking for a terminal command to open many files in preview in "sorted" order. I'd like to open the files in order: 1.pdf, 2.pdf, 3.pdf, 4.pdf, etc. But without first sorting, they are opened ...
anon01's user avatar
  • 123

15 30 50 per page