Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
From what I gather from the text book is that read is used to store inputted information and cat is used to recall stored information. Is this correct?
From what I gather from the text book is that read is used to store inputted information and cat is used to recall stored information. Is this correct?
No. cat writes the content of a file. If no file name is given it reads stdin until it ends. Does your text book explain stdin, stdout and stderr? They are essential concepts for understanding how cat and many other programs work.
No. cat writes the content of a file. If no file name is given it reads stdin until it ends. Does your text book explain stdin, stdout and stderr? They are essential concepts for understanding how cat and many other programs work.
I am unable to locate any of those. the name of my textbook is A practical guide to Fedora and Red Hat Enterprise Linux. If this helps.
The book says when you use cat, it copies a file to standard output. What is stdin??
My main concern would be the same as catkin's original one, ie the script never tells the user to press Ctrl-D so they will be stuck at the command line until they read about this somewhere
or press Ctrl-C which most know will kill something but is incorrect here.
The files name is journal-file, how do I tell it to read this file? is that where the #!/bin/bash comes in to play?
No. That line tells the shell which program is used to interpret the commands in your script.
You have the line
cat >> $file
which says to send the output from cat to the file in the $file (which is journal-file). Without the redirection, you just have
cat
In this case, cat will wait for you to type input at the command line (and terminate it by pressing Ctrl-D). If you want to output the contents of $file to the command line with cat, you use
No. That line tells the shell which program is used to interpret the commands in your script.
You have the line
cat >> $file
which says to send the output from cat to the file in the $file (which is journal-file). Without the redirection, you just have
cat
In this case, cat will wait for you to type input at the command line (and terminate it by pressing Ctrl-D). If you want to output the contents of $file to the command line with cat, you use
cat $file
Does this help?
Should I insert a comment telling to type and then press Ctrl-d after the cat >> $file
Should I insert a comment telling to type and then press Ctrl-d after the cat >> $file
A comment would help anybody looking at the code/script. I guess you would prefer to help people running the script, in which case you could insert an echo giving instructions on the line before the cat.
A comment would help anybody looking at the code/script. I guess you would prefer to help people running the script, in which case you could insert an echo giving instructions on the line before the cat.
Is this right: echo "Input information and then press Ctrl+d" on the line before cat >> $file
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.