Windows 명령 프롬프트에서 LS를 만드는 방법은 무엇입니까?
Windows 명령 프롬프트에서 ls를 사용하고 dir 명령을 실행하고 싶습니다.
어떻게해야합니까?
당신은 할 수 있습니다 :
- 배치 파일을 작성
ls.bat
하고dir
명령 만 포함하도록하십시오. ls.bat
파일이 존재 하는 디렉토리 를PATH
환경 변수에 추가하십시오.
그런 다음 ls
명령 프롬프트에서 실행할 수 있습니다.
하나의 간단한 명령으로이 질문을 해결할 수 있습니다.
echo @dir %* > %systemroot%\system32\ls.bat
cmd.exe
비스타 이상인 경우 먼저 관리자 권한으로 실행하십시오.
오래된 질문이지만 기록은 다음과 같습니다.
http://gnuwin32.sourceforge.net/packages/coreutils.htm
ls와 훨씬 더 많은 것을 제공합니다!
내가 찾은 가장 쉬운 방법은 다음과 같습니다.
- Windows 용 Git 설치
bin
Git 디렉토리를 Path 변수에 추가하십시오 . 내에 위치했습니다C:\Program Files\Git\usr\bin
.- 명령 프롬프트를 시작하고
ls
모든 영광을 즐기십시오 .
해결책이 있지만 더럽습니다.
"dir"만 포함하는 ls.bat라는 파일을 작성하십시오.
C : \ windows \ system32 (또는 PATH env var의 디렉토리)에 넣으십시오.
저것은 작동해야한다!
편집 : 더 일관성있는 것 : https://superuser.com/questions/49170/create-an-alias-in-windows-xp
시스템에 Node.js가 설치되어 있으면 Windows에서 Linux 명령을 위해 작성한 라이브러리 인 Cash 에서 설치할 수 있습니다 .
npm install cash-ls -g
Vista / 7 용 Windows 명령 프롬프트는 NTFS 기호 링크를 허용하고 관리자로 cmd.exe를 실행합니다.
mklink ls %System%\dir.exe
그런 다음 방금 작성한 링크의 위치를 포함하도록 PATH 환경 변수를 설정하십시오.
'ls'명령 이상을 원하면 cygwin을 살펴보십시오 .
편집-방금 깨달은 dir.exe
것은 별도의 프로그램이 아니므로 실제로 작동하지 않습니다. 그러나 mklink
cygwin은 알아야 할 좋은 것들입니다.
위의 게시물에서 +1을 사용하여 git for windows를 설치하고 디렉토리 변수를 경로 변수에 추가하십시오.
다른 방법으로 Windows 8 및 Windows 7 컴퓨터의 cmd.exe에서 작동하는 touch, ls 및 기타 많은 UNIX 명령이 있습니다.
Cygwin을 설치하려면 다음 사이트로 이동하십시오
https://www.cygwin.com/install.html
시스템에 32 또는 64 비트 버전을 설치하십시오. 기본 설정 및 패키지에는 필요한 항목이 포함되어 있으므로 패키지 화면에 도착하면 아무것도 변경할 필요가 없습니다.
설치 후 Cygwin 폴더 경로를 환경 경로 변수에 복사하십시오. 예를 들어; cygwin을 C : \ Cygwin에 설치 한 경우 환경 시스템 경로 변수에 다음을 추가합니다.
; C : \ Cygwin \ bin
내 시스템에 64 비트 버전을 설치했으며 기본 폴더 이름과 경로는 C : \ cygwin64입니다. 그래서 시스템 환경 경로 변수에 다음을 추가했습니다.
; C : \ cygwin64 \ bin
터미널이 열려 있으면 다시 시작하십시오. 그런 다음 ls를 입력하면 디렉토리 목록이 나타납니다.
PATH 환경 변수 설정에 익숙하지 않은 경우 다음을 참조하십시오.
cmd가 ls
에 대한 별칭으로 인식 되도록 dir
하려면이 doskey
명령 에서 수퍼 유저 의 명령을 사용할 수 있습니다 .
dir 명령의 원래 명령 행 매개 변수 처리는 변경되지 않습니다.
당신은 또한 사용할 수 Cygwin에서 그냥 LS는 당신이 사용할 수있는 모든 다른 유닉스 명령 행 도구와 함께 직접 명령을 사용합니다.
내 ls.bat가 아래에있었습니다
@dir %*
cli args를 전송할 수있는
ls /b
ls /w
% windir % 또는 % PATH % 변수의 디렉토리에 넣으십시오.
ANSI 인코딩으로 파일을 저장하십시오. :)
다음 레시피를 권장합니다.
- 사용
DOSKEY
및$*
사용자 생성ls
명령을 사용합니다. - .bat / .cmd 파일에 명령을 기록하여 명령을 지속시키고 파일 경로를 레지스트리에 추가하십시오.
예를 들어, 명령이
DOSKEY ls=dir
DOSKEY sublime="C:\Program Files\Sublime Text 2\sublime_text" $*
$*
인수를 취하는 명령에 유용하게 보일 수 있습니다 . 예를 들어, 여기서 할 수 있기를 원합니다 sublime my_code.c
.
The registry for cmd is at HKEY_CURRENT_USER -> Software -> Microsoft -> Command Processor. Create a string valued entry called AutoRun with the full path of the file (not the containing folder) such as %USERPROFILE%\custom_command.cmd
. Then each time cmd is run, your command will be loaded!
You can add more useful stuffs to the batch file too. See here for an example template.
Another solution that worked for me is to use UnxUtils, which adds multiple utilities from executable files (including ls
, sed
, and grep
).
To use: download source code. Unzip. Add the UnxUtils\usr\local\wbin
path to the Windows PATH variable. Start a new CMD instance.
Surely ls would not work as a unix command for the batches. If you check %1 for -l or -a etc. and all combinations of them, it would work...
You could follow this guide: https://gist.github.com/vladikoff/38307908088d58af206b
TL;DR: pass /K path/to/custom/init_cmd.bat
to your "shell startup" command.
I'm using ConsoleZ as my shell wrapper, so in my case I can find the setup option in "tabs", then I set the shell path to "C:\Windows\System32\cmd.exe "/K C:\cmd_init.bat""
like this.
Where C:\cmd_init.bat
is the batch script containing my macros, here's what I would go for:
@echo off
doskey ls=dir /b
rem other macro stuff..
Sorry for formatting and other mistakes, this is my first time answering here. I hope it helps!
Someone who uses Linux Subsystem for Windows could call ls
from the Linux bash. The following Command creates the ls
Command in System32:
echo @bash -c "ls %*" > %systemroot%\system32\ls.bat
(The Linux Subsystem feature must be enabled/installed first)
Here is my C# source code and binary.
Just add ls.exe somewhere and add the path to the path environment variable.
참고URL : https://stackoverflow.com/questions/9362692/how-to-create-ls-in-windows-command-prompt
'developer tip' 카테고리의 다른 글
vi에서 여러 줄을 어떻게 삭제합니까? (0) | 2020.08.02 |
---|---|
밑바닥 치기를 가진 인조 인간 모양 (0) | 2020.08.02 |
PHP에서 배열 요소의 키를 재설정 하시겠습니까? (0) | 2020.08.02 |
시간을 00:00:00으로 설정 (0) | 2020.07.30 |
Ruby에서 변수가 문자열인지 확인 (0) | 2020.07.30 |