LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help with pipes command (https://www.linuxquestions.org/questions/linux-newbie-8/help-with-pipes-command-862763/)

jabam 02-15-2011 01:43 AM

Help with pipes command
 
Hi all, I am new to this site. I am new Linux. I am working on my assignment and trying to figure out how to come out with a command using pipes. Below is the question.

"Write a command using pipes that displays all of the entries in the /etc/password file that contain the string grunix. Write a similar command that does not use pipes.

Thanks

druuna 02-15-2011 01:44 AM

Hi,

This sure does look like homework.... We are willing to help, but won't do the assignment for you.

What have you tried so far? And what did/didn't work?

EricTRA 02-15-2011 01:46 AM

Hello and Welcome to LinuxQuestions,

LQ users are not in the habit of doing your homework for you. You'll learn a lot more by doing it yourself. Of course if you encounter problems or errors you can always turn to us for help and advice. If you show us what you have done already we might give you some pointers. In the meanwhile you can have a look at Google and do a search for some online documentation, for example this one.

Kind regards,

Eric

Beaten by druuna :)

corp769 02-15-2011 01:50 AM

Since this is a school assignment, don't expect to get any help. Learn on your own.

Edit: Beaten by druuna and erictra.

jabam 02-15-2011 01:58 AM

Thanks for the responses. I guess i might not have worded my question well. What I need help is understanding the string grunix I know about the pipe redirection tool, but I am confused as to what the string "grunix" means and how it is supposed to execute.

Thanks

EricTRA 02-15-2011 02:01 AM

Hello,

A string is just a combination of characters, in this case to be used with a tool to catch the instances of that string you encounter in the password file. Have a look into grep:
Code:

man grep
Kind regards,

Eric

corp769 02-15-2011 02:05 AM

To add to that, also look into awk.

Code:

man awk

jabam 02-15-2011 02:06 AM

Quote:

Originally Posted by EricTRA (Post 4258766)
Hello,

A string is just a combination of characters, in this case to be used with a tool to catch the instances of that string you encounter in the password file. Have a look into grep:
Code:

man grep
Kind regards,

Eric

Thanks. I was able to use grep to write the command. My problem is using the pipe to come out with the same output. Below is what I did and the results. Please look at it and let me know if I am right or wrong.

Code:

jabam@ubuntu:~$ grep jabam /etc/passwd
jabam:x:1000:1000:John Abam,,,:/home/jabam:/bin/bash
jabam@ubuntu:~$

Thanks

druuna 02-15-2011 02:09 AM

Hi,

Grep takes a file as input (the way you do it in post #8), grep also accepts input from a pipe.

cat the file and pipe it to grep: cat file | grep "string"

Hope this helps.

jabam 02-15-2011 02:29 AM

Quote:

Originally Posted by druuna (Post 4258775)
Hi,

Grep takes a file as input (the way you do it in post #8), grep also accepts input from a pipe.

cat the file and pipe it to grep: cat file | grep "string"

Hope this helps.

Oh I see now. Thanks for the help. Your scenario worked. Thanks for the help guys.

EricTRA 02-15-2011 02:35 AM

Hi,

Glad you got a solution. If you consider your problem/question solved then please mark it as such using the Thread Tools.

Kind regards,

Eric

druuna 02-15-2011 02:44 AM

Hi,
Quote:

Originally Posted by jabam (Post 4258798)
Oh I see now. Thanks for the help. Your scenario worked. Thanks for the help guys.

You're welcome :)


All times are GMT -5. The time now is 11:25 PM.