While troubleshooting an issue, I came across these entries given below in one of the shell scripts used by our application. This was written by someone who no longer works in the company and I am trying to figure out what the script does step-by-step. We do have an environment variable $PAT_HOME. By using the % at both the ends, is it calling the environment variable just like $PAT_HOME? In that case, how are using % signs different from using when working with environment variables?

echo "cd " %PAT_HOME%
cd  %PAT_HOME%
# P:
echo "pan.sh -file $kmrfile $logfile_location $csvfile"

sh pan.sh -file $kmrfile $logfile_location $csvfile
  • What's the scripting lang. being used here? %'s are nothing special in bash/bourne.
    – slm
    Nov 22, 2014 at 18:15
  • Is the script expected to work on both Windows and *nix? Could the developer have taken the monumentally inelegant route of providing commands for both systems and just allowing the wrong ones to error out? What happens if you run the script? How is the script being run? Is there a shebang line?
    – terdon
    Nov 22, 2014 at 19:18
  • In our environment, the scheduler function (currently provided by RHEL machines) used to be provided by a Windows machines a few years back. It looks like the developer who modified this script made a mistake of not taking out these lines. I copied it to a test machine and ran the script, it errors out at this line, but continues to run with no issues. Thanks for the answers and comments guys, I just wanted to be absolutely sure that it does not mean anything in bash before taking out those lines and make the script neat.
    – Sreeraj
    Nov 23, 2014 at 4:06

2 Answers 2


It looks like a hybrid between Unix shell script and DOS batch script :)

In DOS the environment variables are access by enclosing the environment variable between %. Like %PATH%, but in Linux this cannot be done.

Just try

$ echo %PATH%

this will not expand the environment variable. But is the script really working ?, because in the later part of the script the variables are accessed with $ but the upper part is accessed with %. Mostly you should get error in cd %PAT_HOME% section unless a file named %PAT_HOME% exist !.

  • I had thought about it, but then this script is there on many of our environments which is functioning very well. So looks like its time to dig deeper into the logs and pick up the errors generated by these windows characters.
    – Sreeraj
    Nov 22, 2014 at 18:26

A Linux scripts Shell are not 100% Compatible with Windows CMD Script , you need make adaptations

Look this Files

1 -> Bash Script

2 -> Batch Script

But if you wanna , you can make a Windows CMD Script , and test with "wine cmd" , its works 100% in wine , in Windows works too

The Env Vars , are not the same , and some things must be write in diferent way

You must log in to answer this question.

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