Bash command to open largest file
I feel like this should be simple, but can't figure it out: What's the bash command(s) to look 开发者_运维技巧through a folder and open the largest file using VIM?
vim "`ls -S | head -1`"
Sort by size, pick just the first. The double quotes make this work if the file name contains spaces or other unusual characters.
FYI, do not use xargs with vim. For most commands the following would also work, but with vim it complains that "input does not come from a terminal" and it can screw up your xterm. (On mine it stopped echoing my input and I had to blindly type reset
to fix it.)
Bad
ls -S | head -1 | xargs vim
精彩评论