Tagged Questions
10
votes
3answers
439 views
What is the difference between “sort -u” and “sort | uniq”?
Everywhere I see someone needing to get a sorted, unique list, they always pipe to sort | uniq. I've never seen any examples where someone uses sort -u instead. Why not? What's the difference, and why ...
2
votes
6answers
133 views
sort ls output by users
On Linux, is there a way to sort ls output by users? What I try to achieve is something like this:
user_a file1
user_a file2
user_b another_file
user_c this_file
user_c ...
1
vote
3answers
56 views
another question with sort in bash [duplicate]
How can I ignore the space in "Kuala Lumpur" when sorting this list? I cheated it by tabbing the columns and sorted on the tab which gives me the right results but I would like to know how to deal ...
1
vote
3answers
90 views
Sort with unequal whitespace in first column
I need to sort this list by name, high temp and low temp:
Kuala Lumpur 78 56
Seoul 85 66
Karachi 95 75
Tokyo 85 60
Lahore 85 75
Manila 90 85
I figured since whitespace is the delimiter for a column ...
4
votes
4answers
190 views
How to shift filename numbers without collisions?
Consider this list of files:
$ touch index-{1,2,3,4,5,6,7,8,9}.txt
If I want to shift them down so they start at zero, it's relatively easy:
$ rename --verbose 's/^index-([1-9])\.txt$/$1/; ...
6
votes
1answer
766 views
How can I remove duplicates in my .bash_history, preserving order?
I really enjoying using control+r to recursively search my command history. I've found a few good options I like to use with it:
# ignore duplicate commands, ignore commands starting with a space
...
8
votes
3answers
720 views
How to sort the string which combined with string + numeric using bash script?
This is the data what I want to sort. But sort treats the numeric to string, the data it no sorted as I expected.
/home/files/profile1
/home/files/profile10
/home/files/profile11
...
4
votes
3answers
410 views
For each subfolder, sort files by name and rename them to sequential padded numbers (regardless of extension)
I have the following directory structure:
.
├── event-a
│ ├── album-a
│ │ ├── a.jpg
│ │ └── x.png
│ └── album-b
│ ├── a.jpg
│ ├── x.png
│ └── y.gif
└── event-b
├── ...
4
votes
1answer
242 views
Renaming files from bash in linux
There is a bunch of files of the following format hh-mm-ss.png where hh, mm, ss are hour, minute and second. How can I rename all these files in the directory in a sequential way from 1.png til n.png ...
5
votes
2answers
228 views
How would I sort these directory names numerically?
I'm aware that I can somehow sort this output numerically (so cpu1/ follows cpu0/) ... I could probably get something to work eventually by splitting up the string various ways with awk, but is there ...
2
votes
3answers
713 views
sorting filenames numerically when they have non-numeric prefix
I have files in the following format: x1 x2 ... x10 x11 ... x101 ...
I want to rename these files, so they all have the same name length: x001 x002 ... x010 ...
I can do this with files, that don't ...
4
votes
1answer
499 views
Is there a search utility which can binary split search a large sorted (sequential) text file?
Yes, I know it sounds odd. Sequential and Binary-splits don't mix.. That is unless the sequence is the byte offset within the file itself...
I've scrambled together a binary split search in bash ...
4
votes
1answer
394 views
Is gnu coreutils sort broken?
Consider the following input to sort:
cat > foo <<EOM
D,,5014978
DD,,25
D,I,1972765530
D,Y,4223624
-,Y,71285059
YA,I,2
EOM
Now try running sort foo
The output is not sorted when trying ...
