LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 11-17-2005, 02:48 PM   #1
steve423
LQ Newbie
 
Registered: May 2002
Posts: 13

Rep: Reputation: 0
Code


Here is the code I'm suppose to type

ps ax / (see note) grep dnrd

My question is the line between the ax and grep is actually a straight up and down line. How do I type it on the keyboard or does it mean type enter and then grep dnrd


Thanks,
Steve


I typed the grep dnrd and nothing happens I type logout nothing happens how to I get out of this screen.


As you probably figured out from the dnrd I'm having problem with DNS or at least I think I am.

Once I type the ps ax how to i scroll up to see the rest of the items in the list?

Last edited by steve423; 11-17-2005 at 02:52 PM.
 
Old 11-17-2005, 02:55 PM   #2
anti.corp
Member
 
Registered: Nov 2005
Location: Copenhagen
Distribution: Debian E, Vectorlinux 5.1std, Arch, Gentoo 2006.0
Posts: 576

Rep: Reputation: 30
Like this:


Code:
ps ax|grep
 
Old 11-17-2005, 02:55 PM   #3
tuxrules
Senior Member
 
Registered: Jun 2004
Location: Chicago
Distribution: Slackware64 -current
Posts: 1,144

Rep: Reputation: 56
It should be a straight-up down line called "pipe". It lets you take output of one program and give it as input to another program.

Code:
ps ax | grep dnrd
ps here is the program whose output is inputed into another program grep. If you are using a english keyboard (qwerty layout) then it is the key just above "enter"...you have to press shift to use it though.

Quote:
Once I type the ps ax how to i scroll up to see the rest of the items in the list?
You have to use a pager program (either more or less) like this.

Code:
ps ax | less

Tux,

Last edited by tuxrules; 11-17-2005 at 02:58 PM.
 
Old 11-17-2005, 02:57 PM   #4
makuyl
Senior Member
 
Registered: Dec 2004
Location: Helsinki
Distribution: Debian Sid
Posts: 1,107

Rep: Reputation: 54
You can scroll up with shift+pageup
 
Old 11-17-2005, 02:57 PM   #5
rshaw
Senior Member
 
Registered: Apr 2001
Location: Perry, Iowa
Distribution: Mepis , Debian
Posts: 2,692

Rep: Reputation: 45
it's a 'pipe' . its location varies depending on the keyboard. it's a shifted backslash on the keyboard i'm using now.looks like two dashes standing on end.

Last edited by rshaw; 11-17-2005 at 02:59 PM.
 
Old 11-17-2005, 03:14 PM   #6
GrueMaster
Member
 
Registered: Aug 2005
Location: Oregon
Distribution: Kubuntu.
Posts: 848

Rep: Reputation: 30
The vertical bar that you type is on the \| key (usually around the backspace key). It actually looks like two stacked bars on most US keyboards. When you see that in a commandline (ex: ls |fgrep jpg), what it tells the shell is to pipe the output (not the errors) from the first command, and feed them as input to the second command.

Here's another example. Say you want a sorted list of jpg files in your home directory (and all subdirectories below), sorted by directory/name:

find ~ -name "*.jpg" |sort

Now, let's assume you also want the file size (but not the date/time, owner, and permissions info):

find ~ -name "*.jpg" -exec ls -lh {} \; | sort | awk '{print $5"\t" $9}'

The first command, find looks in the current users home directory (~) for files that match *.jpg in the name, then fore each file, executes an ls -lh (long ls format with filesize in human readable form) on each file. This output is then passed to sort, and then to awk, which parses each line into space delimited fields (by default), printing out the 9th field (size), a tab (\t), and the path.

The vertical bar can be quite powerful on the command line. There are a lot of other uses that could be scripted on the fly. For example, I use the pipe in a for loop to rename mp3's or convert filenames from all uppercase to lower case.

For more examples of shell scripting, check out the online manuals for
bash or tcsh

Gruemaster
 
Old 11-17-2005, 03:17 PM   #7
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,186

Rep: Reputation: 346Reputation: 346Reputation: 346Reputation: 346
Re: Code

Quote:
Originally posted by steve423
[snip]
My question is the line between the ax and grep is actually a straight up and down line. How do I type it on the keyboard or does it mean type enter and then grep dnrd
[snip]
As rshaw said, it depends on your keyboard. So, fill in your personal information (the "MyLQ" button at the top of the screen) so we can see the country in which you're located. Then, perhaps, you'll get some specific help.

Oh, your keyboard layout usually changes when you change languages, so you might also specify the language you're using. (I.e., the value of LANG displayed by the set command.)
 
Old 11-17-2005, 03:56 PM   #8
steve423
LQ Newbie
 
Registered: May 2002
Posts: 13

Original Poster
Rep: Reputation: 0
Code

Thanks Very, Very helpful I'm using CensorNet which runs on Debain. I work for a small High School and it's the best firewall/web content solution on the market and it's free.

Our DNS is getting hammered and we lose Internet after awhile. It was every 30 min or so but it seems to now go for a day or so. The CensorNet folks are great but I though I'd run it pass you guys as well. I'm still stuck after running grep dnrd I can't seem to get out of this screen, unless I restart. This probably doesn't belong in newbie but I thought the | ? had to have a simple answer Doh!
 
Old 11-17-2005, 07:01 PM   #9
ethics
Senior Member
 
Registered: Apr 2005
Location: London
Distribution: Arch - Latest
Posts: 1,522

Rep: Reputation: 45
out of what screen?? the command should just return the lines containing dnrd and return you to a prompt.

This isn't happening?

ctrl-C kills most things in a terminal
 
Old 11-17-2005, 08:09 PM   #10
steve423
LQ Newbie
 
Registered: May 2002
Posts: 13

Original Poster
Rep: Reputation: 0
It didn't run at all. no command prompt. I could type a command but nothing happened. I had to restart because the Internet went down but thanks for the info.


Steve
 
Old 11-19-2005, 11:33 AM   #11
GrueMaster
Member
 
Registered: Aug 2005
Location: Oregon
Distribution: Kubuntu.
Posts: 848

Rep: Reputation: 30
Quote:
I'm still stuck after running grep dnrd I can't seem to get out of this screen, unless I restart.
If you are running "grep dnrd" as it's own command, then you won't get a return because grep is parsing stdin (standard input). grep takes at least two parameters, the search string, and the search location, which will default to standard input if blank. If you get into that situation, you just hit <ctrl>-c to break out.
 
  


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
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
Editing buttons (quote, code etc.) add the code to the end vharishankar LQ Suggestions & Feedback 2 09-13-2004 09:32 AM
Diffrerence between position independent code and Relocatable code? eshwar_ind Programming 7 05-11-2004 01:40 AM
Open Firmware code for booting OS from SATA : sample code available somewhere ? drsparikh Linux - Hardware 0 03-12-2004 11:16 AM


All times are GMT -5. The time now is 07:48 PM.

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