What's a .sh file?
If you open your second link in a browser you'll see the source code:
#!/bin/bash
# Script to download individual .nc files from the ORNL
# Daymet server at: http://daymet.ornl.gov
[...]
# For ranges use {start..end}
# for individul vaules, use: 1 2 3 4
for year in {2002..2003}
do
for tile in {1159..1160}
do wget --limit-rate=3m http://daymet.ornl.gov/thredds/fileServer/allcf/${year}/${tile}_${year}/vp.nc -O ${tile}_${year}_vp.nc
# An example using curl instead of wget
#do curl --limit-rate 3M -o ${tile}_${year}_vp.nc http://daymet.ornl.gov/thredds/fileServer/allcf/${year}/${tile}_${year}/vp.nc
done
done
So it's a bash script. Got Linux?
In any case, the script is nothing but a series of HTTP retrievals. Both wget and curl are available for most operating systems and almost all language have HTTP libraries so it's fairly trivial to rewrite in any other technology. There're also some Windows ports of bash itself (git includes one). Last but not least, Windows 10 now has native support for Linux binaries.
How to run .sh files in Windows?
cygwin is probably the easiest way.
http://www.cygwin.com/
Alternatively if you're already using git-bash for github etc you can use it to run .sh scripts too.
What is the difference between makefile and sh file
make
automatically checks (based on time stamps) which targets need to be remade and which ones can be left untouched. If you write your own shell script, you'll either have to program this logic yourself or else all your components will be rebuilt when you run your script - even those that haven't changed since the last build.
What is the Bash file extension?
Disagreeing with the other answers, there's a common convention to use a .sh
extension for shell scripts -- but it's not a useful convention. It's better not to use an extension at all. The advantage of being able tell that foo.sh
is a shell script because of its name is minimal, and you pay for it with a loss of flexibility.
To make a bash script executable, it needs to have a shebang line at the top:
#!/bin/bash
and use the chmod +x
command so that the system recognizes it as an executable file. It then needs to be installed in one of the directories listed in your $PATH
. If the script is called foo
, you can then execute it from a shell prompt by typing foo
. Or if it's in the current directory (common for temporary scripts), you can type ./foo
.
Neither the shell nor the operating system pays any attention to the extension part of the file name. It's just part of the name. And by not giving it a special extension, you ensure that anyone (either a user or another script) that uses it doesn't have to care how it was implemented, whether it's a shell script (sh, bash, csh, or whatever), a Perl, Python, or Awk script, or a binary executable. The system is specifically designed so that either an interpreted script or a binary executable can be invoked without knowing or caring how it's implemented.
UNIX-like systems started out with a purely textual command-line interface. GUIs like KDE and Gnome were added later. In a GUI desktop system, you can typically run a program (again, whether it's a script or a binary executable) by, for example, double-clicking on an icon that refers to it. Typically this discards any output the program might print and doesn't let you pass command-line arguments; it's much less flexible than running it from a shell prompt. But for some programs (mostly GUI clients) it can be more convenient.
Shell scripting is best learned from the command line, not from a GUI.
(Some tools do pay attention to file extensions. For example, compilers typically use the extension to determine the language the code is written in: .c
for C, .cpp
for c++, etc. This convention doesn't apply to executable files.)
Keep in mind that UNIX (and UNIX-like systems) are not Windows. MS Windows generally uses a file's extension to determine how to open/execute it. Binary executables need to have a .exe
extension. If you have a UNIX-like shell installed under Windows, you can configure Windows to recognize a .sh
extension as a shell script, and use the shell to open it; Windows doesn't have the #!
convention.
Inherited an AWS Lambda project. What does lambdazip.sh file do & where in AWS do I need to upload it?
From what I see lambdazip.sh
is used to package dependencies from the project's virtual environment and from the project's base path.
What you probably have to do is enable VIRTUALENV
for the project by doing something like python2.7 -m virtualenv
or following this: enable VIRTUALENV. Afterwards you may want to install the dependencies in your virtual environment using pip
. You should be able to run lambdazip.sh
afterwards successfully.
How to run .sh file on Windows10 startup
I'd suggest the same as gazzo, but not with powershell, rather with a virtual shell such as git bash. If possible of course.
Due to how our environments set up at work, i use bash scripts through git bash to download git repositories, setup projects dynamically etc. You could set up windows to run git bash exe and pass in your bash script's path to run it.
How to run in vbscript an .sh file, or how to execute shell script in vbscript?
WshShell.Run "powershell.exe -nologo -command C:\ShellFile.ps1"
Related Topics
How to Use Variables with Brace Expansion
Oracle:Io Exception: the Network Adapter Could Not Establish the Connection
Get Specific Line from Text File Using Just Shell Script
What Does "Make Oldconfig" Do Exactly in the Linux Kernel Makefile
Docker Bash Prompt Does Not Display Color Output
How to Align the Columns of a Space Separated Table in Bash
How to Enable Tab-Completion of Command Line Switches in Bash
Tracking Actively Used Memory in Linux Programs
How to Install The Ncursesw Development Libraries
Using Bash Script to Feed Input to Command Line
How to Find Words from One File in Another File
How to Append the Output to a File
How to Set Limit on Directory Size in Linux
Linux Tool to Send Raw Data to a Tcp Server