Hot answers tagged

135

Damn; I was too quick to ask. I could've done more research. The proper menu option is as follows. For all versions prior to 6.8.3: Edit > Line Operations > Sort Lines in Ascending / Descending Order For version 6.8.3 and following: Edit > Line Operations > Sort Lines Lexicographically Ascending / Descending Select a few lines and your ...


117

I do so love *nix and love seeing the inventiveness that goes into some of these replies... Mine's not nearly as fancy on GNU Linux : alias ls='ls --color -h --group-directories-first' Given that I'm more comfortable with my linux CLI apps, I tend to also update coreutils on OSX : brew install coreutils alias ls='/usr/local/bin/gls --color -h --group-...


68

The easiest method is to use zsh, thanks to its glob qualifiers. print -lr -- $dir/**/$str*(om[1,10]) If you have GNU find, make it print the file modification times and sort by that. find -type f -printf '%T@ %p\0' | sort -zk 1nr | sed -z 's/^[^ ]* //' | tr '\0' '\n' | head -n 10 If you have GNU find but not other GNU utilities, use newlines as ...


51

Use this: find . -printf "%T@ %Tc %p\n" | sort -n printf arguments from man find: %Tk: File's last modification time in the format specified by k. @: seconds since Jan. 1, 1970, 00:00 GMT, with fractional part. c: locale's date and time (Sat Nov 04 12:02:33 EST 1989). %p: File's name.


44

Give this a try: sort -s -n -k 1,1 The -s disables 'last-resort' sorting, which sorts on everything that wasn't part of a specified key. The -k 1 doesn't actually mean "this field and all of the following" in the context of numeric sort, as you can see if you try to sort on the second column. You're merely seeing ties broken by going to the rest of the ...


30

Your sort may have the ability to do this for you: sort --version-sort


27

If you want, you can install GNU sort through GNU's coreutils package over Homebrew, which is a package manager for OS X. Running this would install Homebrew. ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" Then just follow the installation instructions. When Homebrew is installed, run brew install coreutils ...


25

Its a custom sort in the Data sorting. From the Data tab click on the Sort button to open the Sort dialog box, click on Options to open the Sort Options dialog box and select Sort left to right. See here for more info.


24

For this particular example you could also do this: ls *.pdf | sort -k2 -th -n That is, sort numerically (-n) on the second field (-k2) using 'h' as the field separator (-th).


24

You don't need to PHP or Python, just ls: man ls: -t sort by modification time -r, reverse order while sorting (--reverse ) -1 list one file per line find /wherever/your/files/hide -type f -exec ls -1rt "{}" +; If command * exits with a failure status (ie Argument list too long), then you can iterate with find. Paraphrased from: The maximum ...


23

Which Date column is this exactly? As mentioned here, Date is different from Date Created/Modified/Accessed (on Win7 at least, ought to be the same in Win8 as well). It might be slow if the former column type is used and Explorer is trying to extract EXIF data from the files. Try Date Created or Date Modified instead and see if it is still as slow. (If it is,...


22

Use GNU coreutils >= 7.5: du -hs * | sort -h (Taken from this serverfault question) Man page Edit: You can check your versions using du --version and sort --version if you are using the GNU versions. If you're using homebrew you may need to use gdu and gsort.


17

As nixda mentioned in the comments, helper columns will make this possible. You have two options for maintaining the sheet afterward: Add all new IPs in the split helper columns. Repeat the Text-to-columns procedure for new additions. Here's the procedure: Select your IP column and click Data > Text-to-Columns Choose the Delimted option and click ...


16

The following command will list directories first, ordinary files second, and links third. ls -la | grep "^d" && ls -la | grep "^-" && ls -la | grep "^l" Also, it would make a great deal of sense to create an alias for this command to save keystrokes. Edit: If you want directories first, and then everything that is not a directory second, ...


13

To fix the first row select it and then select "Freeze Panes" from the "View" ribbon. To get sorting and filtering select the first row and then "Filter" from the "Data" ribbon.


9

For Mac users coreutils: brew install coreutils alias ls='ls --color -h --group-directories-first' Assuming your system is ready to homebrew:


9

IMO the best way to do this would be to use the programming/scripting language you know best and: load small.txt into an in-memory hash/map/associative array keyed on the words Process huge.txt line by line, adding the column looked up from the hash and writing the result into an output file Buffer input and output so that it happens in chunks of at least ...


9

The default ls in OS X does not have version sort capabilities. This is a feature of GNU ls, which comes with most Linuxes, but does not ship with OS X. You can install GNU ls through the GNU coreutils package. The easiest way of getting it on a Mac is to install a package manager like Homebrew or MacPorts and install coreutils through it. So, for ...


9

This is certainly a dirty workaround, but I figured out a way to do this thanks to @slhck's tip about locales. If a better answer comes along that would be more helpful to others, I'll certainly accept it since this pretty much only works for my specific problem. I set the locale to Spanish (Bolivian) so that the commas were treated like decimal points, ...


9

If by "name order" you mean a simple alphabetical sorting, you could just sort the find results, which works fine as long as the files do not contain a newline in their name: find "$PHOTODIR" -iname "*.jpg" | sort If you want to pass these as arguments to an image viewer—or any other command—you need to pipe them to xargs. This works out of the box as ...


8

If you are referring to GNU sort, it implements a variant of the merge sort algorithm. The coreutils are open source, so feel free to download them and take a look.


8

Couldn't you just extract the 4th and 5th characters into another cell and sort on that? B1: =mid(A1,5,2) Then sort on column b?


7

To only sort on the first column you should do: sort -n -k1,1 From Unix and Linux System Administration Handbook sort accepts the key specification -k3 (rather than -k3,3), but it probably doesn’t do what you expect. Without the terminating field number, the sort key continues to the end of the line


7

To build on Michael Borgwardt's answer: as long as both files are sorted, you can put them together by basically performing one step of a mergesort. It'll be a little different than standard mergesort because you only want to keep one of the files. This will, of course, have to be implemented in your favorite programming language. Here's a sketch of the ...


7

Setting LC_ALL=C restored the traditional sorting order in my case. Package: coreutils Version: 8.5-1ubuntu3 export LC_ALL=C


7

You do only need ls You could do find /wherever/your/files/hide -type f -exec ls -1rt "{}" +; as stated above, or ls -1rt `find /wherever/your/file/hides -type f`


7

Try this: awk '{print $0" "length($4)}' infile | sort -k5,5rn | sed -e 's/ [0-9]*$//' > outfile


7

You need to press Ctrl-Opt-Cmd-Number instead of Ctrl-Cmd-Number. To get the sorting (instead of arranging) menu items, hold down Option. The implemented the Sort by/Arange by submenu somewhat oddly though, so pressing Option while it's already visible won't change the menu items.


7

Try this extension (it is called No Message Pane Sort by Mouse); according to the description: No Message Pane Sort prevents accidental resorting of the message pane by disabling mouse button clicks on the column headers. It is still possible to sort messages by ctrl-clicking the header. I tried it myself: it disables sort button and thus should be ...


7

Output redirection by the shell clears the file's contents before the sort command is run. From man bash: Before a command is executed, its input and output may be redirected using a special notation interpreted by the shell. [...] Redirection of output causes the file whose name results from the expansion of word to be opened for writing [...]. ...



Only top voted, non community-wiki answers of a minimum length are eligible