0

I am a beginner in Unix and I need to write a bash shell script which outputs the message:

I am standard output

to standard output, and

I am standard error

to standard error.

To demonstrate that the script functions correctly, I need to first redirect standard output to

/dev/null 

then redirect standard error to that same file.

I have written the following lines in a script:

echo 'I am standard output'>&1>/dev/null
echo 'I am standard error'>&2>/dev/null

However, I fail to see how I could verify my scripts. Where can I see the /dev/null file? How can I make sure the scripts function properly?

Compo
  • 36,585
  • 5
  • 27
  • 39
Komputer
  • 51
  • 1
  • 16

2 Answers2

0

The whole point of /dev/null is that everything you send to that "file" is automatically discarded. So, you cannot see what is written into it. You would want to direct the output to a different file.

Note that /dev/null is not really a "regular" file in your physical storage drive. Instead, it is a "device file", which is a virtual file controlled by the Operating System, so to speak. For more info about that, you may want to learn from any of the many Unix tutorials on the internet or find a good introductory book. As usual, there is a manual page on /dev/null, but it is not precisely educational.

jp48
  • 1,186
  • 10
  • 17
0

>/dev/null is redundant here.

echo 'I am standard output'>&1
echo 'I am standard error'>&2
Simba
  • 23,537
  • 7
  • 64
  • 76