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-13-2012, 11:43 PM   #1
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Rep: Reputation: Disabled
warning in command's output , but why !


test_3 & test_4 have hey_yo text

daa@daa-Aspire-5740:~$ cat test_4 << test_3
> ahaa
> bash: warning: here-document at line 91 delimited by end-of-file (wanted `test_3')

hey yo

questions are ::
1. why this warning ?
2. why shell is showing > symbol after cat test_4 << test_3 !
 
Old 08-14-2012, 01:22 AM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
The format of the command you entered ('<<') is called a here-document. It allows you to input multiple lines like so:

Code:
cat <<EOF > /etc/resolv.conf
search my.madeup.domain
nameserver 192.168.0.1
EOF
The 'EOF' sequence above is arbitrary and defines a pattern to match when the multiline input is finished. You could just as easily use:
Code:
cat <<monkeysuncle > /etc/resolv.conf
search my.madeup.domain
nameserver 192.168.0.1
monkeysuncle
The command you entered was waiting for 'test_3' on a line by itself to complete the here-document.

Last edited by kbp; 08-14-2012 at 01:23 AM.
 
2 members found this post helpful.
Old 08-14-2012, 02:25 AM   #3
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
Sir "kbp"

i am confused , i am not getting the actual meaning of < & > & << & >>
i know that they are related to input and output .

but please think about this

daa@daa-Aspire-5740:~/only_for_unix$ cat > f_1
hey ya , i am 305
daa@daa-Aspire-5740:~/only_for_unix$ cat < f_1 > f_2

why i am getting output in the screen and thats why i am thinking that there is a precedence in commands also ( like 'C' language) !

please , its a request that clarify this cat < f_1 > f_2 !

Last edited by tushar_pandey; 08-14-2012 at 02:27 AM.
 
Old 08-14-2012, 05:18 AM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,790

Rep: Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650Reputation: 650
It's probably easier to point you to an existing reference, let us know if it's still unclear after you've read this:
http://tldp.org/LDP/abs/html/io-redirection.html
 
Old 08-14-2012, 08:34 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
Please use ***[code][/code] tags*** around your code and data, to preserve formatting and to improve readability. Please do not use quote tags, bolding, colors, or other fancy formatting.

Also, please don't print your entire prompt line when it's not needed. It makes your code more confusing to read. Limit your post to only things that are important for the conversation.


Quote:
2. why shell is showing > symbol after cat test_4 << test_3 !
Because the shell considers the command to be an unfinished multi-line here document, it prints your PS2 prompt and waits for further input from you.

Quote:
$ cat > f_1
hey ya , i am 305
$ cat < f_1 > f_2
The cat command simply copies stdin (or the contents of files) to stdout, like a pipe connecting two sources.

The command "cat > f_1" will redirect anything it receives to file f_1, but since there are no input filenames or "<" redirects given, the input can only come directly from you. Did you type "hey ya , i am 305" yourself after the command? Because that's the only way it would show up normally. Generally running cat with no input means that it will just sit there waiting for some (until it's killed or receives a ctrl+D EOF signal). If you type something and hit enter, it will be redirected directly into the file.

"cat < f_1 > f_2" simply copies the current contents of f_1 into f_2.

If you run "cat < f_1", with no output file, then the contents of file f_1 are printed directly to your terminal, the default stdout.

Last edited by David the H.; 08-14-2012 at 08:36 AM.
 
1 members found this post helpful.
Old 08-14-2012, 08:46 AM   #6
tushar_pandey
Member
 
Registered: Jun 2012
Location: ghaziabad , delhi , india
Posts: 105

Original Poster
Rep: Reputation: Disabled
sorry for mistake ,

its seems , that if i have added any output file to the syntax than it will not produce any input to the terminal !

Last edited by tushar_pandey; 08-14-2012 at 08:53 AM.
 
Old 08-14-2012, 10:56 AM   #7
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,331
Blog Entries: 55

Rep: Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529Reputation: 3529
Quote:
Originally Posted by tushar_pandey View Post
sorry for mistake ,
Yeah, you shoudl be as you posted in the wrong forum as well. Next time please watch where you post threads, OK?
 
  


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
Requests to my ISP server are output in the middle of output by any command I run. stf92 Slackware 2 07-10-2012 09:38 AM
How to redirect the output of exec command output in perl? sudhap85 Linux - Newbie 3 08-28-2009 04:35 PM
Grep on output of command returns all output traigo Linux - Newbie 2 02-24-2009 06:15 PM
How do I parse the output of a command that output to standard out? gauol Programming 9 01-17-2008 02:54 PM
rootkit hunter warning found differences in output kernel modules opto Linux - Security 6 02-06-2007 08:30 PM


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