LinuxQuestions.org
Visit Jeremy's Blog.
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 08-15-2012, 10:16 PM   #1
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Rep: Reputation: Disabled
difference :: cat file_1 & cat < f_1


what is the difference between cat f_1 & cat < f_1

i am asking this question because , i am not getting the reason behind , why cat < - is not working ! thats why i am asking the difference !

Last edited by tushar_pandey; 08-15-2012 at 10:23 PM.
 
Old 08-15-2012, 10:24 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
On my system, these 2 commands do the same thing:
cat filename
cat < filename
 
Old 08-15-2012, 10:44 PM   #3
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
pixellany , in my system also ,

think about this ,
Code:
cat -
works same as
Code:
cat
, and i think "-" is taking input from keyboard !
and now think about this ,
Code:
cat < from_file_1
, and here input is coming from_file_1 ,

now why ,
Code:
cat < -
not working
 
Old 08-16-2012, 08:02 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.8, Centos 5.10
Posts: 17,240

Rep: Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324Reputation: 2324
Try
Code:
cat -
 
Old 08-16-2012, 10:19 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957Reputation: 1957
cat is a command that can read either from a file or from stdin. When you call "cat filename", it's accessing the file directly. When you use "cat <filename", you're asking the shell to send the contents of the file into cat's stdin.

The end effect is the same, but avoiding the redirection is likely slightly more efficient.

Finally, in many commands "-" can be used as a substitute for a filename to mean "read from stdin". This is instead of "<", not in addition to it.

Last edited by David the H.; 08-16-2012 at 10:29 AM. Reason: added last part
 
  


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] cat f_1 > f_2 > f_3 tushar_pandey Linux - Newbie 3 08-15-2012 06:51 AM
difference in cat and vi output keshavk Linux - Newbie 20 04-25-2011 07:18 AM
Cat 6 Cat 5e cable question babbab Linux - Networking 1 04-07-2010 03:33 PM
What's the difference between dd and cat > ? kimchee411 Linux - Newbie 2 02-27-2009 07:28 PM
cat in asm/ cat --show-all option Tux Linux - Software 1 09-02-2006 10:31 PM


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