|
|
|
|
|
by opan
876 days ago
|
|
>So maybe you know that /etc/passwd one way to get that stream on your system, and you decide to use awk for this problem, and type >awk -F: '$6 ~ "bash$" { print $1 }' /etc/passwd I like to apply similar logic to when I use search engines and start broad, narrowing down as needed. If you jump straight to grep or awk you may entirely miss what you were looking for. I frequently search my local IRC logs, and my tool of choice is `less`. I would probably also use that here. You can comfortably get around, all the data is there, and you can search within it. You see adjacent lines which may be relevant to your interests. You could maybe describe this difference in mindset as programmers vs users. I consider myself a user, but not a programmer. Just as in your example, I thought to look in /etc/passwd for the desired info, but I don't understand why you jumped to that gnarly awk one-liner. Maybe the missing context is you were writing some sort of script/program, but the way you framed it read to me like "I want to get this information on a unix-like machine", and as a human I would just open the file in less. Using cat is another option, but I hate when a file was longer than expected and I have to scroll way up after printing it out. Plus, it's easier to search the text with less than it is in my terminal emulator (though tmux scrollback search helps in a pinch). I find that the unix approach to things often feels intuitive from a user-perspective where the cranky programmers who insist using python would be better than working with shell have some alternative solution I can't really grok. Maybe it's just people preferring what they're used to, though. |
|