Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I hope I phrased the question correct. I have a script that makes use of 'sed' a lot. It works great on my ubuntu with the GNU 'sed'. But when I try to run it on BusyBox it fails. Is there a way to get the GNU sed on busybox? I am not a Linux pro.

share|improve this question
Do you have sed installed in busybox? – jokerdino Oct 10 '12 at 12:05
1) What version of Busybox? 2) What errors/unexpected output are you getting? 3) Can you give us an example of a sed operation that works with GNU but not busybox? – RI Swamp Yankee Oct 10 '12 at 13:46
1) BusyBox v1.19.4 2/3) This input {"expires": "Thu, 11 Oct 2012 11:30:29 +0000", "upload_id": "hhgJHflih753jDhhod", "offset": 293876} with sed -n -e 's/.*"upload_id":\s*"*\([^"]*\)"*.*/\1/p' gives the desired output (hhgJHflih753jDhhod) on my ubuntu but not on BusyBox – tzippy Oct 10 '12 at 15:23
up vote 3 down vote accepted

The Busybox iteself may have limited implementation of sed. You can copy the sed binary to some location and invoke it directly pointing it with a full path.

You may fix some incompatibility issues with replacing escapes that BusyBox builtin sed does not support, e.g. replacing the \s escape with [[:space:]] will solve the space-matching issue.

share|improve this answer
removed comment, placed wrong. – tzippy Oct 10 '12 at 15:19
replace the \s escape with [[:space:]]. I think this will solve your problem – Serge Oct 10 '12 at 15:21
Thanks Serge ! Totally did the job! Although there are other locations in the script where replacing \s didnt help. If you post this as answer I'd be glad to accept it! – tzippy Oct 10 '12 at 15:34
@tzippy As you removed your comment with your regexp I just added a note to the answer. – Serge Oct 10 '12 at 15:44

You seem to misunderstand how busybox works. The tool is one single executable that acts in different ways depending on the name (or subcommand) with which it is called. If you call a symlink sed pointing to the busybox binary (or busybox sed), the "sed" functionality will be executed.

To get GNU sed into a busybox environment, you have to remove the sed symlink to busybox and provide a GNU sed binary and the libraries it depends on. You can identify the libraries with the ldd command:

$ ldd /bin/sed =>  (0xb7f78000) => /lib/ (0xb7f56000) => /lib/i686/cmov/ (0xb7e0f000) => /lib/i686/cmov/ (0xb7e0a000)
    /lib/ (0xb7f79000)
share|improve this answer
Oh I did not know that actually! Thanks for pointing it out! – tzippy Oct 10 '12 at 15:17
I just replaced the sed from busybox by downloading the sed package with opkg. this one appearently is the GNU sed. – tzippy Oct 10 '12 at 15:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .