Jump to content
  • Sky
  • Blueberry
  • Slate
  • Blackcurrant
  • Watermelon
  • Strawberry
  • Orange
  • Banana
  • Apple
  • Emerald
  • Chocolate
  • Charcoal
  • 0
Molinko

linux(or UNIX?) Pipes and streams | >> io redirection..

Question

https://www.youtube.com/watch?v=alEiZFmPNP0

 

I saw, in the video above, that the openOS shell supported pipes, streams, and io redirection. Now Im not sure what the heck all that is but it sounds and looked so useful. Could somebody maybe point me to a good reference on how to use these capabilities or maybe explain like im five, but have been using lua for a year.. I've dabbled in most of the data type of lua and know em alright but I'm a total linux/unix noob and could use a hand understanding how and why someone would use this stuff(pipes n such). Thanks for any help in advance.

    - Fast Eddie

Link to post
Share on other sites

3 answers to this question

Recommended Posts

  • 0

The piping is a feature of besh (which can be found on a loot disk). I think currently it's not even horribly broken. To make stuff compatible for piping, basically make sure to use the `io.read` and `io.write` methods instead of operating on the term or gpu directly, besh automatically wraps those.

Link to post
Share on other sites
  • 0

The piping is a feature of besh (which can be found on a loot disk). I think currently it's not even horribly broken. To make stuff compatible for piping, basically make sure to use the `io.read` and `io.write` methods instead of operating on the term or gpu directly, besh automatically wraps those.

 

Thanks for the reply. I was messing around in creative and found the besh disk. What  I was way more curious about t how is something like that used and what is a decent example use case? Could one use it for say logging errors to a file or what?

Link to post
Share on other sites
  • 0

Pipes are use to redirect the output of a program to a file or another program. So, lets say we have a program curl that downloads files from the internet, but doesn't save them. Then we could write the contents of the downloaded file to harddisk like this:

curl http://example.com > example.html

the > redirects the output to the file. We also have < which reads from a file. So if we take for example grep (oppm install grep should work):

grep 'local .- = .*' < file.lua

we give grep the contents of file.lua as input (grep is a kind of silly example, since it can already read files, but it works. 

 

We can use the | to give the output of one program to the next. So if we are for example looking for files with a specific extension, say .lua we could do this:

ls | grep '%.lua'

This should only print the lines that have .lua as extension. 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.