Pipes not working


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Pipes not working
# 1  
Old 05-29-2008
Pipes not working

Hi,

thanks for b4. can anyone tell me why following not working:

noUsers=$(who | cut -d" " -f1 | wc -l)

What i'm trying to do is get a list of logged on users and pass it to 'wc -l' and store the output to a variable. Any ideas?
# 2  
Old 05-29-2008
Quote:
Originally Posted by Furqan_79
Hi,

thanks for b4. can anyone tell me why following not working:

noUsers=$(who | cut -d" " -f1 | wc -l)

What i'm trying to do is get a list of logged on users and pass it to 'wc -l' and store the output to a variable. Any ideas?
Code:
noUsers=`who | cut -d"  " -f1 | wc -l`

thanks
namish
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Programming

Question on pipes in C

If a code forks 2 childs, what can the values be for the process id's of each of the child? I child pid is supposed to be 0, but what if you fork 2 of them? (5 Replies)
Discussion started by: omega666
5 Replies

2. Programming

Problem with pipes

problem solved. (1 Reply)
Discussion started by: superfons
1 Replies

3. Shell Programming and Scripting

Using pipes within variables

Hi, I'm trying avoid having a large number of 'if' statements in my script by setting up a variable within 'ksh' which can be expanded depending on parameters passed to the script. The output from the 'cat' command should be able pipe its output into any additional commands on the command line... (4 Replies)
Discussion started by: stv_t
4 Replies

4. Programming

Pipes in C

Hello all, I am trying to learn more about programming Unix pipes in C. I have created a pipe that does od -bc < myfile | head Now, I am trying to create od -bc < myfile | head | wc Here is my code, and I know I might be off, thats why I am here so I can get some clarification. #include... (1 Reply)
Discussion started by: petrca
1 Replies

5. UNIX for Dummies Questions & Answers

problem with pipes

I have written the following program. The function of this prog is to read data from a file(source.c) and write into another file(dest.c) using pipes. I have just written a line in the source file.Im able to compile and run the program without errors. But the data is not written onto the other... (2 Replies)
Discussion started by: afser
2 Replies

6. UNIX for Advanced & Expert Users

Consolidating Pipes

This is something I've given a lot of thought to and come up with no answer. Say you have a data stream passing from a file, through process A, into process B. Process A only modifies a few bytes of the stream, then prints the rest of the stream unmodified. Is there any way to stream the file... (4 Replies)
Discussion started by: Corona688
4 Replies

7. Shell Programming and Scripting

doubt about pipes

can we use pipes to redirect the output of any command to grep ..... like i wanted to write this script about checking the online status of a certain user so ...can i send the output of who to grep directly using pipes... one way was this : who > temp grep $uname temp i was wondering if... (4 Replies)
Discussion started by: evergreen_cool
4 Replies

8. Programming

pipes inside

Extremely need to understand some aspects of pipes realization. The main question is in which memory are pipes placed? (13 Replies)
Discussion started by: pranki
13 Replies

9. Shell Programming and Scripting

cd using pipes

Hi, Can the cd command be invoked using pipes??? My actual question is slightly different. I am trying to run an executable from different folders and the path of these folders are obtained dynamically from the front end. Is there a way in which i can actually run the executable... (2 Replies)
Discussion started by: Sinbad
2 Replies

10. Filesystems, Disks and Memory

PIPEs and Named PIPEs (FIFO) Buffer size

Hello! How I can increase or decrease predefined pipe buffer size? System FreeBSD 4.9 and RedHat Linux 9.0 Thanks! (1 Reply)
Discussion started by: Jus
1 Replies
Login or Register to Ask a Question