LinuxQuestions.org
Latest LQ Deal: Linux Power User Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 02-15-2011, 02:43 AM   #1
jabam
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Rep: Reputation: 2
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
 
Old 02-15-2011, 02:44 AM   #2
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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?
 
Old 02-15-2011, 02:46 AM   #3
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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
 
Old 02-15-2011, 02:50 AM   #4
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

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

Edit: Beaten by druuna and erictra.
 
Old 02-15-2011, 02:58 AM   #5
jabam
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 2
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
 
Old 02-15-2011, 03:01 AM   #6
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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
 
1 members found this post helpful.
Old 02-15-2011, 03:05 AM   #7
corp769
LQ Guru
 
Registered: Apr 2005
Posts: 5,817

Rep: Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002Reputation: 1002
To add to that, also look into awk.

Code:
man awk
 
1 members found this post helpful.
Old 02-15-2011, 03:06 AM   #8
jabam
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by EricTRA View Post
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

Last edited by jabam; 02-15-2011 at 03:10 AM.
 
Old 02-15-2011, 03:09 AM   #9
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
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.
 
1 members found this post helpful.
Old 02-15-2011, 03:29 AM   #10
jabam
LQ Newbie
 
Registered: Feb 2011
Posts: 5

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by druuna View Post
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.
 
1 members found this post helpful.
Old 02-15-2011, 03:35 AM   #11
EricTRA
LQ Guru
 
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
Blog Entries: 1

Rep: Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295Reputation: 1295
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
 
Old 02-15-2011, 03:44 AM   #12
druuna
LQ Veteran
 
Registered: Sep 2003
Posts: 10,532
Blog Entries: 7

Rep: Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387Reputation: 2387
Hi,
Quote:
Originally Posted by jabam View Post
Oh I see now. Thanks for the help. Your scenario worked. Thanks for the help guys.
You're welcome
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] How to store the output of command with pipes diwaker1984 Programming 3 01-21-2011 12:54 AM
Simplify awk command by reducing pipes keysorsoze Linux - Software 5 10-03-2009 10:19 PM
Problem executing a command with pipes DeepSeaNautilus Programming 12 08-08-2008 02:28 PM
LXer: Using Bash To Feed Command Output To A While Loop Without Using Pipes! LXer Syndicated Linux News 0 08-06-2008 01:10 PM
Write command in named pipes sahel Programming 7 12-28-2005 07:05 AM


All times are GMT -5. The time now is 06:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration