I have a centos box and when I try gsub, it doesn't work:

-bash: gsub: command not found

For the life of me, I can't figure out how to get gsub on my box. Trying to get a script working that checks download speeds on a server. Here is the line:

cachefly=$( wget -O /dev/null http://cachefly.cachefly.net/100mb.test 2>&1 | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}' )

The line isn't outputting correctly, I think because gsub isn't found? It's suppose to print the speed it downloaded the file, the only output I get is "MB/s-"

  • Which gsub are you trying to use? awk? ruby? R?
    – jscott
    Apr 4, 2013 at 2:09
  • It's a part of a bash script. The script also uses the awk command, that works fine on my box Apr 4, 2013 at 2:13
  • 1
    Could edit your question to included the problematic awk incantation? Include any relative script blocks if quoting or scoping may apply.
    – jscott
    Apr 4, 2013 at 2:15
  • On CentOS, awk is GNU awk. Guessing your box (where the command works) is not CentOS? Maybe Ubuntu? On Debian, awk is symlinked to mawk. There are minor differences in their syntax. Can you verify the distros and versions of "awk" your using?
    – jscott
    Apr 4, 2013 at 14:05
  • Linux version 2.6.18-028stab091.2 (root@rhel5-build-x64) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46) ..... cat /etc/*release* = CentOS release 5.3 (Final) ...... awk --version GNU Awk 3.1.5 Apr 4, 2013 at 15:50


You must log in to answer this question.

Browse other questions tagged .