Live data from Hacker News

Stop using tail -f (mostly)

brianstorti.com

201–210 of 211 posts

Re: Stop using tail -f (mostly)

#201
post #127

Earlier quoted context omitted.

Vim ships with a command called `view` that will start it in read-only mode, and makes it very much a viewer — not just an editor.

True, and I like using this for syntax-colored views of files. But it's got an annoying tendency to switch to edit mode with very little fuss. Sometimes I want a viewer to just be a viewer. Speaking of which: are there any Linux/Unix viewers that do have generalized syntax highlighting support?

chmod :)

Re: Stop using tail -f (mostly)

#202

Earlier quoted context omitted.

Another less-vs-vi question: As a junior programmer I got chewed out by my IT department because I was examining a (production) log file in vi. The sysadmin told me I should use less (actually more---this was on Solaris in ~2001). To this day I only read log files with less, but I've never figured out his objection. Negatives to using vi I can imagine are: - I might write to the log file. That seems like a real worry…

If I'm logging into a server later to resolve an issue, one thing I will probably check is the command history. If you open a file with "vi", how do I know that you only looked at it, and did not make any changes to it? When I see "less" in the command history, I know for certain that it was a read-only operation.

Why do you let revs login to production machines. That's your first problem.

Re: Stop using tail -f (mostly)

#203

Earlier quoted context omitted.

Yes and grep isn't very good for interactive searching. There's lot of different ways you could do this, and they all have pros and cons depending on the situation. My point was that all these posts dismissing this blog post as pointless are just arrogant. Most people don't know about less +F, but it's pretty handy for some common use cases. So he didn't mention someone's favourite tool - it's okay.

At no point did I dismiss his post nor show any arrogance towards the author: > Not that I'm trying to dismiss the effectiveness for +F for those inclined > kudos to the author for his recommendation and providing helpful write ups to future sysadmins The ironic thing is, you've been far more dismissive about other peoples suggestions than I had of the author's. As you said yourself, there are a lot different ways th…

Fair enough. My apologies for how that was conveyed.

Re: Stop using tail -f (mostly)

#204

I was introduced to less +F a while ago and it is quite nice, but there is one simple "feature" of tail -f that I miss quite a lot: being able 'mark' the log with gaps by hitting enter a few times. This is especially handy when you have to first load a page or warm up the app before performing the operation you're interested in watching, letting you separate the earlier output from the lines generated by what you're…

That doesn't change the actual log file, however - it's only visual whilst in the screen buffer

Re: Stop using tail -f (mostly)

#205
post #127

Earlier quoted context omitted.

Vim ships with a command called `view` that will start it in read-only mode, and makes it very much a viewer — not just an editor.

True, and I like using this for syntax-colored views of files. But it's got an annoying tendency to switch to edit mode with very little fuss. Sometimes I want a viewer to just be a viewer. Speaking of which: are there any Linux/Unix viewers that do have generalized syntax highlighting support?

You can give vimpager a try. It even supports vimrc. But I have felt it to be considerably slower than less.

Re: Stop using tail -f (mostly)

#206
post #31

Earlier quoted context omitted.

An example of some of the vi commands that less(1) has adopted. You can also: * page forward and backward, including using numeric prefixes to indicate a lineno or indicate "repeat 'n' times". * launch vi if less(1) is working on a file (versus (eg) stdout of some process) * search fwd/backward * start examining a new file w/o leaving less(1) * ...

Another less-vs-vi question: As a junior programmer I got chewed out by my IT department because I was examining a (production) log file in vi. The sysadmin told me I should use less (actually more---this was on Solaris in ~2001). To this day I only read log files with less, but I've never figured out his objection. Negatives to using vi I can imagine are: - I might write to the log file. That seems like a real worry…

Funny - I always used to use less, until this popped up on HN:

http://seclists.org/fulldisclosure/2014/Nov/74

Now I mostly use vi.

Re: Stop using tail -f (mostly)

#208
I just had an SRE screening and one of the questions was

"What is a linux command that's mostly not known?".

I could not remember anything that's special, at least for me at the time but "less -F" poped up to my mind. Thank you :)

Oh now I can think of ccze, column and tac. Interviews..

Re: Stop using tail -f (mostly)

#209

Earlier quoted context omitted.

True, and I like using this for syntax-colored views of files. But it's got an annoying tendency to switch to edit mode with very little fuss. Sometimes I want a viewer to just be a viewer. Speaking of which: are there any Linux/Unix viewers that do have generalized syntax highlighting support?

chmod :)

It took me way too long to grok that.

Re: Stop using tail -f (mostly)

#210
post #185

Earlier quoted context omitted.

From sysop standpoint there is a huge difference: 1) for user: less chance (pun intended) to actually change the file when all you wanted was to read it 2) for sysadmin: if sysadmin sees "less somefile.log" in bash history, he knows the user just read the log. If he sees "vi somefile.log" then he doesn't know if the user has also changed the log file (maybe not even knowing it). The assumption is that you deal with n…

for sysadmin: if sysadmin sees "less somefile.log" in bash history, he knows the user just read the log. If he sees "vi somefile.log" then he doesn't know if the user has also changed the log file (maybe not even knowing it). In case you didn't know, you can invoke an editor from within less by pressing 'v'. And that wouldn't get registered in the shell history ;)

> The assumption is that you deal with non-malicious users...
Post reply on HN