What does "|" mean in a terminal command line? [closed] - linux

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
Sorry for posting it here, but Google does a very bad job when searching for symbols.
What does the "|" mean in:
"some string" | someexecutable.py

It is the pipe symbol. It separates two programs on a command line (see Pipelines in the bash manual), and the standard output of the first program (on the LHS of the pipe) is connected to the standard input of the second program (on the RHS of the pipe).
For example:
who | wc -l
gives you a count of the number of people or sessions connected to your computer (plus one for the header line from who). To discount the header line:
who | sed 1d | wc -l
The input to sed comes from who, and the output of sed goes to wc.
The underlying system call is pipe(2) used in conjunction with fork(), dup2() and the exec*() system calls.

It's called pipe. It gives the stdout of the first command ("some string") as the stdin to the second command (someexecutable.py).

| is a pipe. It sends output of one command as input of the next. It is explained here http://www.ibm.com/developerworks/linux/library/l-lpic1-v3-103-4/#3-pipes

Related

The terminal shows me nothing gives unlimited space to write when i use grep function with file name in linux terminal [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I used this command line to see what is inside grep command but it gives unlimited space to write. Why is this happening grep file.txt
It is finding instances of the literal text file.txt from standard input, aka your keyboard input.
If you want to search a file, use grep PATTERN -f FILE
Check out the grep man page for more details.
Plus, the entire point of grep is to search for a pattern, so you'll need that too.

Using BASH FOR LOOP and PARALLEL [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Just want to check if this is possible to automate in PRALLEL?. I have a bash script that reads a text file line per line and then takes the word of that line as a parameter then it will be processed by the bash script. For sample this would be the format of the text file
TEXT FILE
# cat test.txt
dog
cat
fish
rat
dove
Then line per line will be executed by a separate bash script via loop fashion like these
# for word in `cat test.txt`; do ./MY-BASH-SCRIPT.sh ${word}; done
Well this works fine however I it is executed one by one. May I ask for any suggestion on how can I possibly trigger the words in PRALLEL? I've gone and also read the GNU Parallel and gone some test however got no luck yet
this is now solved via parallel command:
cat test.txt | parallel ./MY-BASH-SCRIPT.sh {}

How to print on stderr without using /dev/stderr [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
How can a linux command script print warnings or error messages without using >/dev/stderr each time?
This should be simple but I don't get it.
Can you post a simple example?
To print to standard error, use a command that writes to standard output (like echo or printf) and redirect the output to file descriptor 2.
echo "This goes to standard output"
echo "This goes to standard error" >&2
This is the most common use of the file descriptor duplication operator, which makes the descriptor indicated by the preceding number (or 1 if omitted) a copy of the descriptor indicated by the following number.
Every unix process always has three open file descriptors when the process starts.
0 is stdin
1 is stdout
2 is stderr
http://man7.org/linux/man-pages/man3/stdout.3.html

How to write a program called biggest that takes any number of arguments [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
So i am trying to write a program called biggest that takes any number of arguments. For all the
arguments that are files, it finds the file with the most words in it, and prints a line
such as:
File whatever has largest number of words (37)
assuming the file called "whatever" has 37 words, which is more (or the same) as
any other files in the current directory. If no arguments were valid files, then the
following line should be printed to stderr: biggest: no valid filenames were specified
The wc command seems like it would be useful, especially wc –w
please guide me with more help!!
Thanks
Put the following in a script and enjoy :
for i; do wc -w $i; done | sort -n | tail -1 | cut -d' ' -f2
PS: No one wants to help when you don't help yourself. For me it was timepass ;-)

Usage of pipe ( | ) in Linux [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 9 years ago.
Improve this question
I am a bit confused regarding the usage of pipe | in python. I need a in depth explanation of its significance. Users please enlighten me regarding this.
Suppose I issued a command, ps aux | grep python then it shows the python processes running on the machine. I do understand it, but I need a analysed and in detail knowledge. Please help me out.
First, it's not Python you're talking about when you run ps aux | grep python, it's unix, usually within a bash shell. Second, the pipe operator means that you're taking the output of the first function and inputting it into the 2nd function.
In this case, you're taking the result of your process list from ps aux and finding anything to do with python from it using grep python. The grep command means that you're searching for the string "python" within the process list outputted by ps.
That command you listed is a shell command, not anything to do with Python specifically. You are saying:
"run the command ps aux and, instead of showing me the result, provide the result as input to grep python". Or, in other words, "pipe the output of the first command into the input of the second command".
grep accepts input and displays as output all of the lines of the input that contain the argument following grep. So grep python shows all lines in ps aux that contain the word python.
Python here is not being invoked in any way -- you're just filtering for that literal string, python, in ps aux.
| works as and of the two statement ps aux and grep python
So when you type ps aux | grep python it will return the common results of the two statement.

Resources