LinuxQuestions.org
Review your favorite Linux distribution.
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 12-20-2003, 07:50 AM   #1
286
Member
 
Registered: Nov 2003
Location: London
Distribution: SuSE
Posts: 130

Rep: Reputation: 15
newbie questions about "pipe" command


i did linux:/ # cd /etc | ls in terminal, and which i thought the command means go to /etc directory and then list the files in /etc directory. but actually the output is:
. bin cdrom dev etc home media opt root srv usr
.. boot data1 dvd floppy lib mnt proc sbin tmp var


it just ran the "ls" command, --- it didn't go in... could anyone give me a correct command? i felt abit confused. thanks.

 
Old 12-20-2003, 07:55 AM   #2
irish_rover
Member
 
Registered: Sep 2002
Location: IN, USA
Distribution: Debian, Endian FW
Posts: 368

Rep: Reputation: 30
Just run ls against the directory you want to list. ( ls /etc ) The if you want you could pipe that through something like less. (ls /etc | less)
 
Old 12-20-2003, 08:37 AM   #3
286
Member
 
Registered: Nov 2003
Location: London
Distribution: SuSE
Posts: 130

Original Poster
Rep: Reputation: 15
ok... i think i misunderstood the function of "pipe" command. need to fix it. thx mate
 
Old 12-20-2003, 04:31 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
If you want to cd and get a listing at the same time, do 'cd /etc; ls'. A pipe connects one command's stdout to another's stdin. But cd doesn't exactly have any output to pass to ls. It'd be interesting to know what exactly ls does with the cd command. Probably 'WTF is this? Off to the bitbucket with you,' but I dunno. Anyway - the semi-colon just strings commands together sequentially on the same line.
 
Old 12-20-2003, 07:44 PM   #5
286
Member
 
Registered: Nov 2003
Location: London
Distribution: SuSE
Posts: 130

Original Poster
Rep: Reputation: 15
great! thank you so much!
 
Old 12-20-2003, 08:09 PM   #6
Kristijan
Member
 
Registered: Sep 2003
Location: Melbourne, Australia
Distribution: NetBSD 3.0.1, Slackware 10.1
Posts: 394

Rep: Reputation: 30
286, you can also use &&

cd /etc && ls

If the first command is succesful, then the 2nd command is executed.
 
Old 12-20-2003, 08:25 PM   #7
286
Member
 
Registered: Nov 2003
Location: London
Distribution: SuSE
Posts: 130

Original Poster
Rep: Reputation: 15
ahha! thats it! thanks guys!
 
  


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
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 05:08 PM
metacharacters "The Pipe command mikeinanson Linux - Newbie 4 03-11-2006 01:36 PM
Linux "make" command questions. schapman43 Linux - Hardware 12 09-03-2005 12:26 AM
"Extra-newbie" Questions cHaOtiC Linux - Newbie 1 01-04-2003 05:30 PM
"What distribution is right for me?" and other confused newbie questions. Joe Molotov Linux - Newbie 3 09-10-2001 02:23 PM


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