HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free and registered users see less advertising! If you just want to browse through the existing questions, just select the forum that you want to visit from the selection below. Otherwise, click here to register!. We highly recommend that you print a copy of our Guide for New Members. Enjoy!

linux pipe command questions

1.using a pipe count the number of files in the a directory
2.Count the number of files that have dot (.) in the their name
3.how to Creat a file named "number" that contains the number of users currently logged in .
i was told to use pipe and I/O redirection

This looks like school homework, so I wouldn't feel anything but guilty if I gave you the answers. The pipe allows you to "pipe", or add commands to another command. For instance, using the command grep to find the process httpd.

# ps ax | grep httpd

For your exercises, you might try reading the man pages for grep, and wc.

how i solve this one...??

5. Prints out the login names (and only the login names) of the four users that most recently logged to your UNIX machine. Tip: use the last command to print out the last logins and grep to filter out irrelevant lines of the output

itried to solve it ,
each time i enter the console it regesters as a login
even thow i didnt loged out of the system.

so the problem is that after i opened the console box 4 times
the command:
last -4|cut -d" " -f1| uniq -u

it only showed a single user.
another problem is that if i change it to : last -50
it showed the same user multiple times.

how to i make a command that will show the last 4 users that logged in,
and that they will show only 1 time???

printing out last 4 logged users

Originally Posted by googler

5. Prints out the login names (and only the login names) of the four users that most recently logged to
so the problem is that after i opened the console box 4 times
the command:
last -4|cut -d" " -f1| uniq -u
it only showed a single user.
another problem is that if i change it to : last -50
it showed the same user multiple times.
how to i make a command that will show the last 4 users that logged in,
and that they will show only 1 time???

your command works, but only if 4 different users log in, I've tried and :