as1mov48
Posts: 5
Joined: Tue Jun 12, 2018 10:16 pm

entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 8:09 am

I'm totally new to Linux but I'm really exited about its potential.
At present attempting to use a 2.5" SATA H/D as a boot device and so far i've got all the info I need.
One thing I don't have a clue about is the logical OR operation (pipe symbol). How does one enter this symbol using the terminal window.

ie. echo program_usb_boot_mode=1 OR sudo tee -a /boot/config.txt

How do I express the 'OR operation' as the pipe symbol?
Thanks in anticipation.
as1mov :?:

DirkS
Posts: 9027
Joined: Tue Jun 19, 2012 9:46 pm
Location: Essex, UK

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 8:12 am

See the response to your other post...
viewtopic.php?f=29&t=213827&p=1327636#p1327646


See @BGoode's post below
Last edited by DirkS on Wed Jun 13, 2018 8:43 am, edited 1 time in total.

B.Goode
Posts: 6426
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 8:24 am

[Superseding the response from @DirkS, my reply in your other thread is now appended below.. ]



On a UK keyboard (I have no experience of any other) the pipe is the Shifted ('uppercase') version of the \ backslash.

If your keyboard configuration does not match the setting used by the operating system it would be a good idea to fix that soon, before it causes further confusion. There is an option in the raspi-config utility to do this.

But finally: this 'one liner' is simply one way of editting the config.txt file to append the program_usb_boot_mode directive. It is possible to simply use a standard editor to modify the file /boot/config.txt to append program_usb_boot_mode=1 as a new final line.

hippy
Posts: 3750
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 9:01 am

On a UK keyboard there are often two vertical bar pipe characters; one which is '¦' above the '\' key at the bottom left which is a split vertical bar, and '|' which is to the left of the '1' key, along with the back-tick '`' and '¬', which is a non-split vertical bar.

What one actually gets depends on what keyboard mapping or code page has been selected, and what one gets may not be what is shown on top of the key caps.

I imagine it will be the same for keyboards with other layouts, those for other languages and locales.

as1mov48
Posts: 5
Joined: Tue Jun 12, 2018 10:16 pm

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 11:00 am

Thanks to everyone, the keyboard i was using didn't have a left slash, when I looked at the keyboard on my PC all became clear.
I'm truly grateful and AMAZED at the response, in such a short time at my amateurish query |||||.
Now to get to work on this beautiful wee piece of kit.
i'm truly humbled.

W. H. Heydt
Posts: 8864
Joined: Fri Mar 09, 2012 7:36 pm
Location: Vallejo, CA (US)

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 6:44 pm

And just to close the loop on all this, the '|' symbol is an 'or' to some program languages, but in writing commands to be processed by bash it is, as stated "pipe", which means that it takes the output from one process and sends it as input to another process. No logical operations are performed on the data by this action.

Thus...
ls -a | grep <pattern>
will take the output from ls -a and send it to grep, which will then display only those lines that have the specified pattern in them. A longer way to accomplish the same result would be...
ls -a > tempfile
grep <pattern> tempfile

jahboater
Posts: 2908
Joined: Wed Feb 04, 2015 6:38 pm

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 7:00 pm

Its also often called a FIFO (first in, first out).
That is, the first byte the producer writes to the pipe is the first byte the consumer reads (compare that to a LIFO which is a stack).

Its popular and intuitive, for example people often write:-

cat xxx | sort

instead of

sort <xxx

User avatar
rpdom
Posts: 12803
Joined: Sun May 06, 2012 5:17 am
Location: Ankh-Morpork

Re: entering the logical OR operation (pipe symbol) in terminal

Wed Jun 13, 2018 7:31 pm

jahboater wrote:
Wed Jun 13, 2018 7:00 pm
Its also often called a FIFO (first in, first out).
That is, the first byte the producer writes to the pipe is the first byte the consumer reads (compare that to a LIFO which is a stack).

Its popular and intuitive, for example people often write:-

cat xxx | sort

instead of

sort <xxx
or

sort xxx

The use of cat and pipes when not necessary is something that pains me. :-(

Return to “Beginners”

Who is online

Users browsing this forum: Baidu [Spider] and 34 guests