.sh 파일이란 무엇입니까?
그래서 나는 과다한 파일 유형을 다루는 경험이 없으며 .sh
파일이 정확히 무엇인지에 대한 많은 정보를 찾을 수 없었습니다 . 내가하려는 작업은 다음과 같습니다.
개별적으로 다운로드 할 수있는 타일에 배열 된지도 데이터 세트를 다운로드하려고합니다. http://daymet.ornl.gov/gridded
한 번에 다양한 타일을 다운로드하기 위해 스크립트를 다운로드하라고 말하면 결국 https://github.com/daymet/scripts/blob/master/Bash/daymet-nc-retrieval.sh 로 이어집니다 daymet-nc-retrieval.sh
.
그렇다면이 코드로 정확히 무엇을해야합니까? 웹 사이트는 사용자가 어떻게해야할지 알고 있다고 가정하고 추가 지침을 제공하지 않습니다. 브라우저에 대해 언급되지 않은 다른 응용 프로그램에 코드를 붙여 넣어야한다고 생각합니다 (이 경우 Chrome 또는 Firefox 사용)? Firefox / Greasemonkey에 붙여 넣을 수있는 것처럼 보이지만 정답은 아닙니다. 파일 유형에 대한 빠른 Google만으로는 앞면이나 뒷면을 얻을 수 없었습니다.
이 파일로 무엇을해야하는지에 대한 간단한 설명이 있다고 확신하지만 사람들이 이미이 파일로 무엇을해야하는지 알고 있다고 가정하고있는 많은 게시물에 묻혀있는 것 같습니다. 실제로 구현하는 코드가있는 페이지로 이동 한 후 스퀘어 원에서 수행해야 할 작업을 간단히 말하려는 사람이 있습니까? 감사.
브라우저에서 두 번째 링크를 열면 소스 코드가 표시됩니다.
#!/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
그래서 그것은 bash 스크립트입니다. Linux가 있습니까?
어쨌든 스크립트는 일련의 HTTP 검색에 불과합니다. wget과 curl은 대부분의 운영 체제에서 사용할 수 있으며 거의 모든 언어에 HTTP 라이브러리가 있으므로 다른 기술로 다시 작성하는 것은 매우 간단합니다. bash 자체의 일부 Windows 포트도 있습니다 (git에는 하나가 포함됨). 마지막으로 Windows 10은 이제 Linux 바이너리를 기본적으로 지원합니다 .
확장자가 .sh 인 파일이란 무엇입니까?
그것은이다 Bourne 쉘 스크립트 . UNIX와 유사한 다양한 운영 체제에서 사용됩니다. "언어"가 없으며 쉘 (터미널 명령 해석기)에 의해 해석되거나 첫 번째 행이 다음 형식 인 경우
#!/path/to/interpreter
그들은 그 특정 통역사를 사용할 것입니다. 파일에는 첫 번째 줄이 있습니다.
#!/bin/bash
이는 Bourne Again Shell (bash라고하는 Bourne Again Shell)을 사용함을 의미합니다. 그것은 모든 실용적인 목적을 위해 좋은 오래된 sh를 대체합니다.
통역사에 따라 파일이 작성되는 언어가 다릅니다.
UNIX 환경에서는 파일이 무엇인지 결정하는 파일의 확장자가 아니라는 점을 기억하십시오 (셸 스크립트 실행 방법 참조).
DOS / Windows 사용자라면 확장명이 .bat 또는 .cmd 인 파일 (배치 파일)에 익숙 할 것입니다. 내용이 비슷하지는 않지만 디자인이 비슷합니다.
쉘 스크립트를 실행하는 방법
일부 어리석은 운영 체제와 달리 * nix는 파일로 수행 할 작업을 결정하기 위해 확장에만 의존하지 않습니다. 권한도 사용됩니다. 즉, 다운로드 한 후 셸 스크립트를 실행하려고하면 텍스트 파일을 "실행"하려는 것과 동일합니다. ".sh"확장자는 사용자의 편의를 위해 해당 파일을 인식하기위한 것입니다.
파일을 실행 가능하게 만들어야합니다. 파일을로 다운로드했다고 가정하면 file.sh
터미널에서 실행할 수 있습니다.
chmod +x file.sh
chmod
파일의 권한을 변경하고 +x
실행 권한을 설정하고 (이 경우 모든 사람에 대해) 마지막으로 파일 이름을 지정하는 명령입니다.
GUI에서도 할 수 있습니다. 대부분의 경우 파일을 마우스 오른쪽 버튼으로 클릭하고 속성을 선택할 수 있습니다. XUbuntu에서 권한 옵션은 다음과 같습니다.
If you do not wish to change the permissions. You can also force the shell to run the command. In the terminal you can run:
bash file.sh
The shell should be the same as in the first line of your script.
How safe is it?
You may find it weird that you must perform another task manually in order to execute a file. But this is partially because of strong need for security.
Basically when you download and run a bash script, it is the same thing as somebody telling you "run all these commands in sequence on your computer, I promise that the results will be good and safe". Ask yourself if you trust the party that has supplied this file, ask yourself if you are sure that have downloaded the file from the same place as you thought, maybe even have a glance inside to see if something looks out of place (although that requires that you know something about *nix commands and bash programming).
Unfortunately apart from the warning above I cannot give a step-by-step description of what you should do to prevent evil things from happening with your computer; so just keep in mind that any time you get and run an executable file from someone you're actually saying, "Sure, you can use my computer to do something".
sh
files are unix (linux) shell executables files, they are the equivalent (but much more powerful) of bat
files on windows.
So you need to run it from a linux console, just typing its name the same you do with bat files on windows.
Typically a .sh file is a shell script which you can execute in a terminal. Specifically, the script you mentioned is a bash script, which you can see if you open the file and look in the first line of the file, which is called the shebang or magic line.
I know this is an old question and I probably won't help, but many Linux distributions(e.g., ubuntu) have a "Live cd/usb" function, so if you really need to run this script, you could try booting your computer into Linux. Just burn a .iso to a flash drive (here's how http://goo.gl/U1wLYA), start your computer with the drive plugged in, and press the F key for boot menu. If you choose "...USB...", you will boot into the OS you just put on the drive.
A .sh file is a shell file. It can be used to open programs and what not.
open the location in terminal then type these commands 1. chmod +x filename.sh 2. ./filename.sh that's it
참고URL : https://stackoverflow.com/questions/13805295/whats-a-sh-file
'Development Tip' 카테고리의 다른 글
iOS Safari / Chrome / Firefox에서 클릭 한 링크에서 회색 배경 제거 (0) | 2020.11.16 |
---|---|
HttpClient 헤더를 추가하면 일부 값이 포함 된 FormatException이 생성됩니다. (0) | 2020.11.16 |
ASP.NET MVC에서 이미지 주위에 Html.ActionLink를 만드시겠습니까? (0) | 2020.11.16 |
레일은 특정 마이그레이션을 실행합니다. (0) | 2020.11.16 |
Proper use of mutexes in Python (0) | 2020.11.16 |