[완료]shell I/O 재지향에 관한 질문입니다

ceraki의 이미지

(ls 파일1 파일2 2>&1) 1>&2|egrep \* >file
ls 파일1 파일2 2>&1 1>&2|egrep \* >file
ls 파일1 파일2 1>&2 2>&1|egrep \* >file

위의 명령에서 에러파일과 표준출력파일이 어데로 출력되는지 왜서 인지
설명해 주시면 고맙겠습니다.꾸벅~
주:파일1은 존재하는 파일이고 파일2는 존재하지 않는 파일입니다.

kewlbear의 이미지

시험문제 또는 숙제인 것 같군요.

ceraki의 이미지

아닌데요..
제가 지금 셀을 공부하고있는데요..
재지향이 잘 이해가 안가서..@_@

ceraki의 이미지

아시는분 없으세요??@_@

익명 사용자의 이미지

몰라요

ymir의 이미지

먼저 자신이 생각하는 바를 적어주셨더라면 오해를 피하기 쉬웠을텐데요..;;

(ls 파일1 파일2 2>&1) 1>&2|egrep \* >file
=> (something) 의 결과를 stderr 로 redirect 했기 때문에, 모든 출력은 stderr 로 나가서,
file 에는 아무것도 저장되지 않습니다.

ls 파일1 파일2 2>&1 1>&2|egrep \* >file
=> 먼저 stderr 는 stdout 에 연결되어 있고, stdout 을 stderr 로 보냈기 때문에,
모든 출력은 stdout 으로 나가서, file 에는 에러와 'ls 파일1'의 결과가 저장되고,
터미널에는 아무것도 출력되지 않습니다.

ls 파일1 파일2 1>&2 2>&1|egrep \* >file
=> 먼저 stdout 은 stderr 에 연결되어 있고, stderr 를 stdout 으로 보냈기 때문에,
모든 출력은 stderr 로 나가서, file 에는 아무것도 저장되지 않고,
모든 결과는 바로 터미널에 출력됩니다.

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

ceraki의 이미지

안녕하세요~
우선 답글 고맙구요^^잘 이해안가는거 있어서요..@_@
처음것은 이해가 가는데 두번쨰 하구 세번째 잘 이해가 안가네요
ls 파일1 파일2 2>&1 1>&2|egrep \* >file
에서 "먼저 stderr 는 stdout 에 연결되어 있고, stdout 을 stderr 로 보냈기 때문에,
모든 출력은 stdout 으로 나가서"라고 하셨는데요..왜 "모든 출력은 stdout 으로 나가"죠?
2>&1 기떄문데 stderr 는 stdout 에 연결되였으므로 에러와 출력은 모두 stdout로 가고요
또 1>&2 기떄문에 stdout로 연결된 모든것이 다시 stderr로 연결되므로
모두 stderr로 가는거 아니세요?
2>&1 1>&2 기떄문에 모든것이 stderr로 나가야 하는거 같은데....
좀더 상세히 설명해 주시면 고맙겠습니다 꾸벅~~^oo^

ymir의 이미지

ls 파일1 파일2 2>&1 1>&2|egrep \* >file 에서....

2 -> 1 -> 2 으로 연달아 보내지는게 아닙니다.

순서대로 연결을 생성하고, reverse order 로 적용된다고 이해하시면 될 것 같습니다.

먼저 2 -> 1 로 연결이 일어났기 때문에...

뒤에 (any) -> 2 로 추가하더라도 결과적으로 먼저 생성된 연결에 의해..

(any -> 2) -> 1 로 보내지는겁니다..

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』

ceraki의 이미지

^_^ 알것같네요 떙큐~~

댓글 달기

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