Tag Info

Hot answers tagged

96

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'


65

Damn, I was too quick in asking, without doing a better research. Proper menu option is in here: Edit > Line Operations > Sort Lines in Ascending / Descending Order If you select few lines, only your selection will be sorted. If there's no selection -- entire file will be sorted.


53

If you have GNU find, make it print the file modification times and sort by that. We use NUL-terminated lines to be compatible with all file names. find -type f -printf '%T@ %p\0' |sort -zk 1nr |sed -z 's/^[^ ]* //' |xargs -0n1 If you have Perl (here I'll assume there are no newlines in file names): find . -type f -print | perl -l -ne ' $_{$_} = -M; ...


36

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 ...


24

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.


22

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


21

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.


21

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).


20

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 ...


20

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.github.com/Homebrew/homebrew/go/install)" Then just follow the installation instructions. When Homebrew is installed, run brew install coreutils This will ...


19

Its a custom sort in the Data sorting. See here for more info.


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 ...


13

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, ...


10

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

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

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 ...


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 ...


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, ...


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?


8

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


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

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


7

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


7

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.


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

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 [...]. ...


6

With brace expansion, which is available in Bash 3 and above, as well as Zsh and several other shells:* mv IMG_{9431..9999}.jpg some_other_dir The braces will be expanded to all the numbers between 9431 and 9999, so it is equivalent to writing out this: mv IMG_9431.jpg IMG_9432.jpg … IMG_9999.jpg some_other_dir This will fail if there are too many ...


6

Based on xl2007 (but I doubt differs for Office 2010): In B1 enter =RIGHT(A1,3) and copy down as required. Copy ColumnB and Paste / Special / Values over the top. Sort ColumnA:B AZ with Sort by ColumnB.


6

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 ...


6

It means Sort by Track Number. It's mostly used for audio CDs or audio files with Track Number info.



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