473,320 Members | 1,838 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Multiple Pipes (shell scripting)

I have a script which starts out with:

ls -lhagG | grep ^d
ls -lhagG | grep ^-

but I would like to be able to do something like this:

ls -lhagG ls's output to grep ^d and then ls's output to grep ^-

so I don't have to run ls twice. I can't find a howto I can understand. I think what I need to use is named pipes but I'm not sure.
Jul 11 '07 #1
3 5218
For now I'm using the "write to a file in /tmp/" method...it works pretty good.
Jul 12 '07 #2
Ok...I figured it out. You have to make everything that accesses that pipe run at the same time with &.

Kind of obvious now that I think about it :)

[resolved]
Jul 12 '07 #3
Motoma
3,237 Expert 2GB
Ok...I figured it out. You have to make everything that accesses that pipe run at the same time with &.

Kind of obvious now that I think about it :)

[resolved]
To clarify, the solution was:

ls -lhagG | grep ^d & grep ^-
Jul 12 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Christian Hammers | last post by:
Hello I would like to call a unix shellscript from within a PHP script and - write data to its STDIN - read data from its STDOUT *and* STDERR - get its exit code afterwards proc_open seems...
2
by: Orr, Steve | last post by:
Oracle provides an export utility (exp) and I have a shell script which compresses its output (not stdout) thru a pipe but l need a platform portable Python script for this. Here's the shell...
2
by: Serge A. Ribalchenko | last post by:
Hi all, I'm new in python coding... Can someone point me how can I do such a usual thing? I need to ping some hosts, and harvest results in one list. Just cause there is about 120 hosts in the...
5
by: Peng Yuan Fan | last post by:
Hi, sorry if you found I have multi posted in different groups. It didn't appear in that group. I am trying to write an automated testing program with CxxTest, which in turn needs to talk to gdb...
3
by: E.U. | last post by:
Hello, I need to program grep (like the one UNIX has but more simple) For example if the programs name(the grep I will write) is p3 then if I write in shell p3 story.txt word The output...
2
by: vmalhotra | last post by:
Hi I am new in python scripting. I want to open a Multiple telnet session through once script. In other way i can tell i want to open two linux consoles through one script. I wrote one...
7
by: Frank Potter | last post by:
I learned some python in windows. And now I've turned to linux. I read a book and it teaches how to write shell script with bash, but I don't feel like the grammar of bash. Since I know about...
3
by: ZhukovL | last post by:
I'm having some trouble implementing the handling of multiple pipes in a shell I'm writing. I was hoping someone could point me in the right direction because I really cant see where I'm going...
0
by: limweizhong | last post by:
I don't know why the following script intermittently crashes when I remove the sleep() call. I believe the pipes were not properly set yet before the shell statement was called, which used pipes...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.