LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Code (https://www.linuxquestions.org/questions/linux-newbie-8/code-384086/)

steve423 11-17-2005 02:48 PM

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?

anti.corp 11-17-2005 02:55 PM

Like this:


Code:

ps ax|grep

tuxrules 11-17-2005 02:55 PM

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,

makuyl 11-17-2005 02:57 PM

You can scroll up with shift+pageup

rshaw 11-17-2005 02:57 PM

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.

GrueMaster 11-17-2005 03:14 PM

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

PTrenholme 11-17-2005 03:17 PM

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

steve423 11-17-2005 03:56 PM

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!

ethics 11-17-2005 07:01 PM

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 :)

steve423 11-17-2005 08:09 PM

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

GrueMaster 11-19-2005 11:33 AM

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.


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