Using Pipes and Redirection

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Using Pipes and Redirection
# 1  
Old 02-16-2010
Using Pipes and Redirection

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:
Create a pipe to show the number of people who are logged into the system right now.

Create a pipe to show how many files you have in your home directory.



2. Relevant commands, code, scripts, algorithms:
who




3. The attempts at a solution (include all code and scripts):
who | count
who | number




4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):
Kansas State, Manhattan, KS Brian Hucklebee CS146
# 2  
Old 02-16-2010
A very simple thing is,

Code:
who | wc -l

If you want to be more clear and right, then

Code:
who | cut -d' ' -f 1 | uniq | wc -l

# 3  
Old 02-16-2010
Tools number of files in directory

Code:
>ls | wc -l

shows # files in current directory
Code:
>ls ~| wc -l

shows # files in home directory
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Pipes with the < and >> meanings.

Hey, Well, we're starting scripting next week for my class, and I have my command done, but I don't actually understand what the meaning is, so I was just wondering if someone could "translate" this in to words so that I might be able to do this better... command1 | command2 | command3... (5 Replies)
Discussion started by: sso
5 Replies

2. 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

3. 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

4. Shell Programming and Scripting

Possible to combine inline redirection with pipes?

Would like to use a here document in a shell script with sqlplus and pipe the output to sed (etc.) before ultimately redirecting the lot to a file, e.g: # sqlplus -S user/pass <<EOF SELECT * FROM table quit EOF | sed 's///g' > outputfile Have tried various permutations to no avail. Any... (2 Replies)
Discussion started by: cs03dmj
2 Replies

5. UNIX for Dummies Questions & Answers

Named Pipes

hi, i am working on a script for oracle export, m using a parameter file... i want to compress the dump file that is generated.. in my script following is the code i have written. i am not able to generata .gz file mknod /tmp/exp_tesd1_pipe p gzip -cNf... (4 Replies)
Discussion started by: saharookiedba
4 Replies

6. Shell Programming and Scripting

Help with pipes in a file

I have to add pipes for particualr number of records in a file. For eg the file has 10 records and i need to add the "|" for records numbers 7 to 10 at particular positons as shown. I need to add pipes in each of these records at positions 9, 11,,21 as like below. Can some body... (7 Replies)
Discussion started by: dsravan
7 Replies

7. Shell Programming and Scripting

how to use pipes + redirection to create two files?

# this works # creates two.txt (echo one;echo two;echo three;) | ( ( grep two > two.txt ) ) # wamt this to create two files: # two.txt containing "two" and three.txt containing "three" # Both files get created, but three.txt is empty # is there a way to do this? (echo one;echo two;echo... (3 Replies)
Discussion started by: tphyahoo
3 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