1

My console is not able to recognize ic command in a bash script.

I need to run this command to do some calculation but I get this message ic: command not found.

How could I define it in the bash?

5
  • 3
    What is it supposed to do?
    – Thilo
    May 6, 2013 at 0:29
  • 4
    It would help if we knew what that command was, or where it comes from. May 6, 2013 at 0:29
  • Talking about calculations, maybe you're referring to bc or dc? May 6, 2013 at 0:31
  • ic is a calculator similar to bc but with more capability. It was renamed some time ago but I can't find the new name at the moment. You'll have to install the new package and either change your script to use the new name or link the new name to ic. I'll see if I can find the new name.
    – garyjohn
    May 6, 2013 at 20:55
  • Eureka! It's now called nickle and you can find it at nickle.org.
    – garyjohn
    May 6, 2013 at 21:10

3 Answers 3

3

The error message that you are getting indicates that the command ic is not present in any of the directories contained in the PATH environment variable.

To find the directories that bash searches for executable files type the following at the command line

echo $PATH

If you know where the ic command is on your file system then you could specify the full path to ic in your bash script so that it does not have to use the PATH environment variable to find it.

So lets say that ic was in the directory /usr/local/bin then in your bash script you could execute ic by entering.

/usr/local/bin/ic

rather than

ic
1
  • 2
    (or OP could add add PATH=:$PATH:/usr/local/bin someplace in their environment.) Good luck to all.
    – shellter
    May 6, 2013 at 1:25
2

The message ic: command not found. indicated that the command ic was not found. In other words, it is not in one of the places where your shell looks for the command.

Usually this is because the command is in the current directory, which (unlike in the default in windows) is not in the default search path.

If this is the case then you can either start it with supplying the full path or by adding the path it is in to the search path.

Examples:

  • /usr/local/bin/ic to start a program called ic in the folder /usr/local/bin/
  • /opt/bin/ic to start a program called ic in the folder /opt/bin/
  • ./ic to start a program called ic in the current directory.
    Note this is not in the path by default. If you add it to a path, make it the last entry. E.g use PATH=:$PATH:. and not PATH=.:$PATH. ($PATH is the old path, the colomn is a separator, the dot is the current directory).

If ic is a script then you can also start it by invoking its interpreter.

For example if ic is a bash script then you can use /usr/local/bin/bash ic

If ic is a script and the current directory is already in you path then check these three things:

  1. The program (ic) has its execute bit set. (If that is not the case then chmod +x ic).
  2. The script has a shebang specifying a proper interpreter.
    A shebang is the #! at the very first line in the script. It must be the first line. No empty lines above it. For a bash script the proper entry is #!/usr/local/bin/env bash. (#!/usr/local/bin/bash will also work if your bash is in /usr/local/bin, but if you move to another system where it is installed in a different place then you will need to edit that file. The env program (which is always installed in the same place) solves that issue.)
  3. If it is a script and there is a shebang, make sure that it has a proper line ending. This is something which often goes wrong when a script is edited on Windows which uses a different line ending than unices. (^J^M on windows, ^J on unix, and ^M on a Mac). The result is that env might be looking for a program called bash^M, and this might not be obvious when a helpful (as in clippy style helpful editor decides to help you by not showing the ^M's).
2

ic is now called nickle, as explained here. You can obtain it from nickle.org, but it would be better if you could use your distribution's package manager as I think it has some dependencies. For example, on an Ubuntu system, you can install it with

sudo apt-get install nickle

Then you can either change your script to use nickle instead of ic, or you can link nickle to ic, e.g.,

ln -s /usr/bin/nickle ~/bin/ic

You must log in to answer this question.