awk equivalent in busybox.

Posted on 2006-03-31
Last Modified: 2012-06-27
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
Question by:dinkarece
    LVL 5

    Expert Comment

    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?


    Author Comment

    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.

    LVL 5

    Accepted Solution

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

    Author Comment

    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.

    Author Comment

    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.


    Author Comment

    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.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Maximize Your Threat Intelligence Reporting

    Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

    Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
    The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…
    This video discusses moving either the default database or any database to a new volume.

    758 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    10 Experts available now in Live!

    Get 1:1 Help Now