유닉스 명령어에 대한 질문(cp, mv)

SeaSky의 이미지

유닉스 명령어에 대해서 질문이 있는데요.
파일명령어인 cp, mv의 차이점이 알고 싶습니다.

1.
cp /A/a.txt /B/b.txt
mv /A/a.txt /B/b.txt

위의 명령어를 쓸 때 b.txt는 cp나 mv에서 파일복사 또는 이동이 완전히 끝나기 전에 다른 유저가 읽을 수 있나요? 용량이 적은 파일이면 금방 실행이 되겠지만 그렇지 않고 큰 파일 명령에 대해서 실행을 하면 문제가 될 것 같은데 아시는 분 알려주세요.

2.
cp명령을 쓰면 내용을 복사하는것은 알겠는데,
mv명령을 쓸 때는 어떻게 동작이 되는지요?
먼저 cp를 하고나서 성공하면 기존 파일을 삭제한다.
윈도우처럼(정확히는 모르지만) 위치정보만 바꾸어서 사용자에게 알려준다.
어느쪽인지요?

참고로 레드핫 리눅스를 쓰고 있습니다.
cp, mv의 소스를 구할 수는 있나요?

그럼, 아시는분의 조언부탁드립니다.

feanor의 이미지

cp, mv 등은 GNU Coreutils의 일부로, http://www.gnu.org/software/coreutils/ 에서 소스 코드를 다운받으실 수 있습니다.

only2sea의 이미지

제가 알기로는...

mv에서 복사는 필요한 경우에 일어납니다. 예를 들어서 다른 디스크 파티션으로 옮긴다던지... 윈도에서도 비슷한 방식으로 동작합니다.

이제는 서명에 무엇을 써야하는지 생각해보자.

SeaSky의 이미지

두분 답변감사합니다.

소스는 조금 어렵네요. 스타일이 보통 보던 거랑 틀리니깐 이해가 잘 안갑니다만 차분히 함 읽어보겠습니다.
mv명령에 대한 설명 감사합니다. 조금은 이해가 되었습니다. 그래서 조금씩 틀리다고 생각이 든 거군요.

마잇의 이미지

같은 파티션 내에서라면 mv는 inode 정보를 수정하는 것으로 완료가 될 것 같습니다. 다른 파티션이라면 데이터 자체도 복사를 해야겠지만요.

추측입니다. ^^
--
마잇


--
마잇

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.