1

I need to convert a batch file to a shell file to run it on Ubuntu. I'm new with bash scripting so would you please help me with a piece of the script?

My batch code is :

::Version detector
set Sverion=%~dp0\*.jar

FOR /f %%i IN ("%Sverion%") DO (
set SOver=%%~ni
)

Would you please explain what set Sverion=%~dp0\*.jar means and how I can convert it to shell?

Thank you, Diana

Martin Vidner
  • 2,307
  • 16
  • 31
  • possible duplicate of [Can a Bash script tell what directory it's stored in?](http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in) – jeb Jan 21 '15 at 13:36
  • @jeb I considered marking it as a duplicate of that but that assumes one knows the answer to the question being asked here; namely "What does `~dp0` do in a batch script?". – Etan Reisner Jan 21 '15 at 16:14
  • @EtanReisner That's right, but that's also easy to get by search [What does %~dp0 mean, and how does it work?](http://stackoverflow.com/q/5034076/463115) – jeb Jan 21 '15 at 16:18
  • Then I'd mark it a dup of that ticket and add a comment for the bash one. – Etan Reisner Jan 21 '15 at 16:24

1 Answers1

1

Explanation of ~dp0 can be found at http://en.wikibooks.org/wiki/Windows_Batch_Scripting#String_processing.

The equivalent can be found at How do I determine the location of my script? I want to read some config files from the same place. and also the first "Related" post listed in the sidebar of this post.

Etan Reisner
  • 77,877
  • 8
  • 106
  • 148