LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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, 09: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 09:23 PM.
 
Old 08-15-2012, 09:24 PM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
On my system, these 2 commands do the same thing:
cat filename
cat < filename
 
Old 08-15-2012, 09: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, 07:02 AM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,369

Rep: Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753Reputation: 2753
Try
Code:
cat -
 
Old 08-16-2012, 09:19 AM   #5
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Arch + Xfce
Posts: 6,852

Rep: Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037Reputation: 2037
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 09:29 AM. Reason: added last part
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:44 AM.

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
Open Source Consulting | Domain Registration