Tag Info

Hot answers tagged

74

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'


46

If you have GNU find, make it print the file modification times and sort by that. I assume there are no newlines in file names. find . -type f -printf '%T@ %p\n' | sort -k 1nr | sed 's/^[^ ]* //' | head -n 10 If you have Perl (again, assuming no newlines in file names): find . -type f -print | perl -l -ne ' $_{$_} = -M; # store file age (mtime - ...


31

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


19

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


19

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


18

Use GNU coreutils >= 7.5: du -hs * | sort -h (Taken from this serverfault question) Man page


18

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


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

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


16

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


15

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.


12

Damn, I was to 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.


11

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


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

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

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?


7

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


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


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

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.


6

Actually, it is possible to do this, with a little trickery. You need to edit the Finder's preference file to turn on the options that the View Options panel's disabled buttons equate to. To accomplish this, you need to edit the com.apple.finder.plist preferences file which should be located in the following folder: /Users/~/Library/Preferences/ I use ...


6

The minus sign is ignored in the first pass. So the first pass sorts 1, 11, 1a, 11a. Since 1 < a, you get 11a < 1a and thus 11-a < 1-a. - is a variable collation element, meaning that you/the implementor can choose to ignore it. The glibc implementation apparently does so. In practice, most punctuation is affected by this behavior. You can ...


6

The output you show is sorted alphabetically instead of numerically. Try adding: -n, --numeric-sort compare according to string numerical value Edit: I just noticed that in your output the file size column appears to be the 6th one! have you tried -nk6? Tested on my Hardy Heron, these work: ls -al | sort -nk5 ls -al | sort -k5n ls -al | sort ...


6

You can use Picard. It can be configured to move files into a hierarchy based on their metadata. It can also use the MusicBrainz database to correct your metadata...if you want it to. Of course, you could also do this with a single command on a unix system. I doubt that's what you want though.


6

I don't think you can do that. I guess the closest way is to right click an empty area and select "Group By" -> "Date".


6

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


6

Something like this might do what you want, though it takes a slightly different approach: pdftk $(for n in {1..18}; do echo cwcch$n.pdf; done) cat output output.pdf



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