awk equivalent in busybox.

I have an embedded linux box that has busybox. I have some scripts that use awk that I want to run on this embedded system. awk support is not implemented in my busybox and am looking for an equivalent of awk command to replace in my scripts.

I am enclosing utilities that are built in my busy box.

Any help is appreciated.


# busybox
BusyBox v0.60.5 (2006.02.07-22:24+0000) multi-call binary

Usage: busybox [function] [arguments]...
   or: [function] [arguments]...

        BusyBox is a multi-call binary that combines many common Unix
        utilities into a single executable.  Most people will create a
        link to busybox for each function they wish to use, and BusyBox
        will act like whatever it was invoked as.

Currently defined functions:
        [, ash, basename, busybox, cat, chgrp, chmod, chown, chroot, chvt,
        clear, cmp, cp, cut, date, dd, df, dirname, dmesg, du, echo, env,
        expr, false, find, free, freeramdisk, grep, gunzip, gzip, halt,
        head, hostname, id, ifconfig, init, insmod, kill, killall, klogd,
        linuxrc, ln, logger, ls, lsmod, md5sum, mkdir, mknod, modprobe,
        more, mount, mv, nc, pidof, ping, poweroff, printf, ps, pwd, reboot,
        rm, rmdir, rmmod, sed, sh, sleep, sort, stty, sync, tail, tar,
        tee, telnet, test, time, top, touch, tr, traceroute, true, tty,
        umount, uname, uniq, update, uptime, usleep, vi, watchdog, wc,
        which, whoami, xargs, yes, zcat
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Hi dinkarece,

awk is in the Editors sub menu of the busybox config. If you're using an embedded linux box, I presume you've built busybox yourself and can rebuld it with a new config? Or am I missing something?

dinkareceAuthor Commented:
Thanks for your quick reply.

No, I haven't built the busybox. I have a system that somebody else has built it and am trying to run scripts on that.

One of the statements that include awk include:

NODE_MAJOR=`awk "\\$2==\"$1\" { print \\$1 }" /proc/devices`

May be I should build the busybox myself with awk support if there is no other way.

Building busybox is very easy, so it may well be worth your while. Sorry I can't be of any more help.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

dinkareceAuthor Commented:
Thanks for your reply.

Can somebody explain this statement:

`awk "\\$2==\"$1\" { print \\$1 }" /proc/devices`

I assume \\$2==\"$1\" is testing some condition. I understood the \ before " which is used to tell the shell that \"  \" is a separate string but I didn't understand about the preceeding of two \\ before $1 and $2. I tried to find the nitty details  of this \\ but couldn't find it on google.

Thanks for your help.
dinkareceAuthor Commented:
OK I guess now I have an understanding.

`awk "\\$2==\"$1\" { print \\$1 }" /proc/devices`

\\$2 is the second argument resulting from the awk command.

\"$1\" is the first argument on the command line.

\\$1 is the first argument resulting from the awk command.

So, \\ is used because it is enclosed in ` ` and if we don't enclose it in `` (while running from a command line), we just use \$1 instead of \\$1.

dinkareceAuthor Commented:
I figured it out without recompiling the busybox.

Basically, I was getting the major number for a particular module from /pro/devices/

Instead of awk, I can use

grep 'plxDrv' | cut -d ' ' -f1

That gives me what I want.

Thanks for your replies.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Linux OS Dev

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.