LinuxQuestions.org
Share your knowledge at the LQ Wiki.
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 09-27-2004, 11:45 PM   #1
kyborg
LQ Newbie
 
Registered: Feb 2004
Posts: 2

Rep: Reputation: 0
linux commands help


hi, i got stuck on these questions -_-, seems to be dumb, but no, i dont know how:
----------------------
A pipe is a Unix mechanism for directing (piping) the output of one program or command to become the input of another program or command. For example, consider the two commands who and less. less outputs the contents of its input (for example, a file) onto the screen in such a way that is pauses after each screenful. who lists information about every user session currently on the system. If there are more sessions than lines on the screen, the top lines will scroll off before we get a chance to see them. If we make the output of who go through a pipe to become the input of less, then less will pause after a screenful, displaying the top lines originally output by who.

A pipe is indicated by the character "|"; the command described above would look like this: who | less. Pipes let you chain commands on a single line; each command takes as its input the output of the previous command.

1. Assume you have a program called Large.class which prints many lines of output to the screen,. Give a one-line command (try man java) that will run Large and display the output, sorted alphabetically.
2. One of the pieces of information printed by who, described above, is the id of the terminal used in a given session. Give a one-line command to list only the session associated with a terminal named "tty22". Try looking at grep.
------------------------------
Make sampledir your current working directory. You want to know which files in the current directory contain the word "Canada".

1. What command do you use to display only the filenames of the files in the current directory that contain "Canada"?
2. What if you didn't care about the case of the letters (e.g., could be "Canada", or "CANADA" or "cAnaDa")?
--------------------------------
Suppose myfile contains 100 lines. How do you display, with a one-line command, just lines 50 through 70 (inclusive) of myfile?



Thanks a bunch
 
Old 09-28-2004, 12:01 AM   #2
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 46
I don't do java
1. java whatever | sort -n
2. who | grep tty22

1. grep -l Canada files
2. grep -il Canada files

sed '50,70!d' myfile

Last edited by darthtux; 09-28-2004 at 12:04 AM.
 
Old 09-28-2004, 12:08 AM   #3
kyborg
LQ Newbie
 
Registered: Feb 2004
Posts: 2

Original Poster
Rep: Reputation: 0
beautiful, i love u man.... i dont even know when i will use those commands
 
Old 09-28-2004, 12:48 AM   #4
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,275

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
If you ever get a job using Unix seriously (developing or administering), you will use them all the time, so better get comfortable with them.
 
Old 09-28-2004, 02:31 AM   #5
darthtux
Senior Member
 
Registered: Dec 2001
Location: 35.7480 N, 95.3690 W
Distribution: Debian, Gentoo, Red Hat, Solaris
Posts: 2,070

Rep: Reputation: 46
Quote:
Originally posted by kyborg
beautiful, i love u man.... i dont even know when i will use those commands
I don't know what you plan on doing with Linux, but if you plan on doing anything besides surfing the web, playing games, music, or videos, then I would learn them. Just take your time and look at some good docs.

http://jamesallen.dyndns.org:3000/bookmarks/index.html
 
  


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
linux commands zexter Linux - Newbie 5 11-04-2004 03:37 PM
linux commands shafie Linux - Newbie 1 05-01-2004 03:07 PM
Linux commands Delmarc Linux - Newbie 9 10-22-2003 11:39 PM
Linux commands Shikha Linux - General 3 11-27-2002 10:40 AM
Linux Commands AMDPwred Linux - General 23 01-11-2002 01:23 PM


All times are GMT -5. The time now is 09:01 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