[완료] mkdir 실패이유가 동일 이름 파일이 존재

oosap의 이미지

제목과 같습니다.
mkdir 로 폴더를 생성하려 했습니다.

mkdir Server

결과는

mkdir: `Server' 디렉터리를 만들 수 없습니다: File exists

Server 라는 실행파일이 존재하기는 합니다. 그런데 저는 파일을 생성하려던 것이 아니고 폴더를 생성하려던 것이거든요...
우분투 LTS 입니다.

mkdir 할 때 이 문제 어떻게 해결할 수 있을까요?

미리 감사드립니다.

unipro의 이미지

해당 경로의 같은 이름의 파일을 삭제하고 디레토리를 만드면 됩니다.

[ -d "Server" ] || rm -f "Server" && mkdir "Server"

내 블로그: http://unipro.tistory.com

oosap의 이미지

알려주신 문장을 이해를 못하겠어요... __;
[ -d "Server" ] 가 무슨 의미인가요?
쉘스크립트 관련 내용을 찾아보면 알 수 있을까요?

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

oosap의 이미지


[] 테스트
-d 파일테스트 연산자
&& 조건 테스트
|| 조건 테스트

출처 : http://wiki.kldp.org/HOWTO/html/Adv-Bash-Scr-HOWTO/index.html

아마도 폴더도 하나의 파일이기 때문에 mkdir 이 폴더와 파일을 같이 취급하지 않나 ... 짐작해봅니다.

감사합니다.

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

세이군의 이미지

Server라는 파일이 있으면 Server라는 디렉토리는 만들 수 없습니다.
반대로 Server라는 디렉토리가 있으면 Server 라는 파일은 만들수 없습니다.
같은 이름의 파일과 디렉토리는 만들수 없으나 파일시스템이 대소문자가 구별하므로 server라는 소문자만으로 된 파일이나 디렉토리는 만들 수 있습니다.

oosap의 이미지

아 그렇군요..
윈도우즈와 다른 점이네요..

감사합니다.

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

planetarium의 이미지

윈도에서도 중복되는 이름의 파일과 폴더는 동시에 만들수 없습니다.
윈도에서는 기본적으로 확장자가 숨겨지기 때문에 착각할 수 있습니다.

Server.txt 파일과 Server 디렉토리는 동시에 존재할 수 있지만,
Server 파일과 server 디렉토리, 혹은 Server.txt 파일과 server.txt 디렉토리는 동시에 존재할 수 없습니다.

oosap의 이미지

정말 그렇군요..
아 이거 참 컴퓨터 처음쓰는 것 같네요..
윈도우즈도 마찬가지군요..
감사합니다.

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.