On 24Dec2014 06:50, Paul Cartwright <pbcartwright@xxxxxxxxx> wrote:
On 12/23/2014 05:19 PM, Cameron Simpson wrote:
and just for grins, try
man awk... 2032 lines... and the example shows:
You're complaining that awk has documentation?
oh no! that just means there are lots of options, arguements.....
complex command:)
It is a whole programming language.
EXAMPLES
Print and sort the login names of all users:
BEGIN { FS = ":" }
{ print $1 | "sort" }
um, so, how does awk work there??
That is an example awk program. I would expect to feed it the
/etc/passwd file as input.
I would usually grep password, looking for a specific name... nice to
have a sorted list though.
AWK's not doing the sorting there.
The real advantage (in this tiny example) is that awk splits lines into fields
for you. Instead of using grep and writing special regexps to get fields
(tedious for anything except the first field), if you use:
awk -F: 'program-text-here...' /etc/passwd
then the login field is $1 and so on. Then you can work more directly and
readably.
Cheers,
Cameron Simpson <cs@xxxxxxxxxx>
Don't have awk? Use this simple sh emulation:
#!/bin/sh
echo 'Awk bailing out!' >&2
exit 2
- Tom Horsley <tahorsley@xxxxxxxxxxxxxx>
--
users mailing list
users@xxxxxxxxxxxxxxxxxxxxxxx
To unsubscribe or change subscription options:
https://admin.fedoraproject.org/mailman/listinfo/users
Fedora Code of Conduct: http://fedoraproject.org/code-of-conduct
Guidelines: http://fedoraproject.org/wiki/Mailing_list_guidelines
Have a question? Ask away: http://ask.fedoraproject.org