
makefile의 스크립트를 읽을 때 다음 Linux 스크립트 명령을 만나게 됩니다.
mv obj/*.o . 2>/dev/null
이 명령은 무엇을 의미합니까? 폴더 에 mv obj/*.o .
접미사가 있는 모든 파일이 현재 폴더로 이동된다는 것을 이해합니다 . 무슨 뜻인가요? 그것들이 결합되면 목적은 무엇입니까? 감사해요!o
obj
2>
답변1
당신은보고있다출력 리디렉션(Bash). 2는 오류 출력인 'stderr'을 나타냅니다. 로 방향을 바꾸면 /dev/null
망각 상태로 버려지는 것입니다. 하지만 일반 출력인 'stdout' 또는 1은 여전히 표시됩니다(기본적으로 터미널에).
기본적으로 이는 명령의 오류 출력을 침묵시키는 것입니다 mv
.
위 링크의 스니펫은 보다 일반적인 설명을 제공합니다.
COMMAND_OUTPUT >
# Redirect stdout to a file.
# Creates the file if not present, otherwise overwrites it.
ls -lR > dir-tree.list
# Creates a file containing a listing of the directory tree.
[..]
1>filename
# Redirect stdout to file "filename."
1>>filename
# Redirect and append stdout to file "filename."
2>filename
# Redirect stderr to file "filename."
2>>filename
# Redirect and append stderr to file "filename."
&>filename
# Redirect both stdout and stderr to file "filename."
답변2
그런데 때로는 화면에 표시되는 것을 방지하고 파일로 캡처하고 싶을 수도 있습니다. 그렇다면 다음과 같이 할 수 있습니다.
mv obj/*.o . > move.log 2>&1