4 ms·
cat file.txt is always worthless. Best case scenario, you will end up with text that fits into one scree, but more often than not you will have to retype the co
by levihaku 3y ago
cat file.txt is always worthless. Best case scenario, you will end up with text that fits into one scree, but more often than not you will have to retype the command with $EDITOR filename or less filename anyway and now you just wasted (precious) time doing what could've been done few seconds ago.
Sure, few seconds isn't a lot, to someone who opens terminal once a year.
- sverona 3y agoSure, if I know it's bigger than my screen I'll open another terminal and use less. But I can generally tell if that's the case from the filesize.
- omnibrain 3y agoDepends on how your terminal(-emulator) behaves in conjunction with the scroll lock key.
- pxc 3y agoIf you're using a terminal multiplexer to handle scrollback, you can navigate the output using your usual pager whether you explicitly invoked it in the pipeline or not. And that leaves it searchable in your scrollback history even after you've gone on to run several more commands, unlike if you pipe it directly to a pager. Additionally, if you're using a nicer colorizing pager, like bat, it'll automatically send the output to your pager for you when it detects that the output wouldn't fit on screen. For both of those reasons, I almost never use `less` directly on a file.
- bloopernova 3y agoAfter your cat command has run, type 'vim ' then hit the escape key plus the period/full stop key. That inserts the previous command's parameters/arguments at the cursor. Obviously you don't have to use vim, any other editor or whatever can be used.
- quesera 3y ago> inserts the previous command's parameters/arguments at the cursor In zsh, there are equivalent expansions: !!:1 previous command line, arg 1 (zero-indexed) !!:$ previous command line, LAST arg !!:1-$ previous command line, args 1-end (zero-indexed) So, e.g.: cat /etc/passwd /etc/shadow /etc/group vi !!:1-$ (becomes) vi /etc/passwd /etc/shadow /etc/group
- bloopernova 3y agoNice! I'll have to add those to my wall of index cards with useful commands.
- quesera 3y agoI use !!:$ occasionally. If I wanted to do the cat/vim switcheroo you described, I'd more likely do: <UpArrow><Esc>vcwvi<Esc>:wq<Enter><Enter> Which is a greater number of keypresses, but more flexible and requires less thought. ...as they say: Unix is user-friendly — it's just choosy about who its friends are.
- boring_twenties 3y agoThose all work in bash too, I believe they come from csh
- tedunangst 3y agocat file leaves the contents on my screen as I compose my next shell command, as opposed to erasing them as quitting the editor flips back from the alt screen.
- quesera 3y agoI sometimes use the following prevent screen clearing when exiting vi: :set t_te= Useful because vi makes it more convenient to select the chunk of file I want to view after exiting. More convenient than cat/head/tail at least. Competitive with more. :)
- scbrg 3y agoMy terminal emulator has supported scrollback since I started using it in '95. I didn't get the impression at the time that it was a particularly new feature :)