How can I edit a file if there is no vi, vim, joe, etc?

In that instance, I'd try transferring files out and editing them on another computer, then transfer them back. If you have ssh, you should have scp (I hope), so you should be able to push files in and out. If not, you can also look for ftp to transfer files in and out.

If not, then I think your best option is to try and make use of cat, grep, sed, echo, and I/O redirection (especially append with >>). And lots of temporary files.

Though if you have access to perl (or something similar), you can run it with no arguments and it will let you input a script source from standard input. Once you press ctrl+d, it can then run the script. You could use that method to create a file. It would be more powerful than hacking something on the command line as I mentioned before.


One way would to be to output the result of an echo.

echo "foo" > bar.txt

This will make a file titled bar.yxy with the containing text, "foo".


Assuming you're SSH'ing into your router, you can also use various utilities to transfer the file back and fourth to your computer/router. You can download a copy on your PC, modify it, and then SSH it back to the router via SFTP (see Putty or WinSCP if you're a Windows user).

If you're using a custom firmware on the router/gateway, however, you may be in luck. There are various Optware packages containing simple (and small) text editors. Depending on your needs, you could get the nano package, or just go for busybox which contains vi.