[clug] IO redirection

Bryan Kilgallin (iiNet) kilgallin at iinet.net.au
Sun Sep 17 14:11:39 UTC 2017


Thanks for your interest, Kim:

> fish Test.txt

That actually worked! The desired result appeared beneath a Buddhist 
saying. Displayed by the following package.

display-dhammapada

> . Test.txt

WTF? That worked too! But I can't find documentation explaining the use 
of `.' as a command. Please refer me to such an explanatory page.

> exec Test.txt

That yielded the following error.
{
Test.txt: command not found
fish: exec Test.txt
            ^
}

> But that is probably not what you want to do.

I had been reading through the fish shell documentation. Trying to get 
my head around the concepts. And also learning the syntax.
{
Most programs use three input/output (IO) streams, each represented by a 
number called a file descriptor (FD). These are:

     Standard input, FD 0, for reading, defaults to reading from the 
keyboard.
     Standard output, FD 1, for writing, defaults to writing to the screen.
     Standard error, FD 2, for writing errors and warnings, defaults to 
writing to the screen.

The reason for providing for two output file descriptors is to allow 
separation of errors and warnings from regular program output.

Any file descriptor can be directed to a different output than its 
default through a simple mechanism called a redirection.

An example of a file redirection is echo hello > output.txt, which 
directs the output of the echo command to the file output.txt.

     To read standard input from a file, write <SOURCE_FILE
     To write standard output to a file, write >DESTINATION
     To write standard error to a file, write ^DESTINATION
     To append standard output to a file, write >>DESTINATION_FILE
     To append standard error to a file, write ^^DESTINATION_FILE
     To not overwrite ("clobber") an existing file, write 
'>?DESTINATION' or '^?DESTINATION'
}
http://fishshell.com/docs/current/index.html
-- 
www.netspeed.com.au/bryan/



More information about the linux mailing list