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 07-13-2018, 05:35 AM   #1
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Rep: Reputation: 0
Issue with cat


Hello

I ran into this while training with command line.

When I use cat program without arguments, enter a line and press enter it copies said line to next paragraph like this:
Code:
$ cat
This is line0
This is line0
To my knowledge I haven't changed any variables permanently at least on purpose and couldn't find information how to revert this back to normal. I also tried to search logs, but couldn't find an answer.

There's been a lot new information for me to handle during last days so I'm not sure if I remember correctly, but this isn't how that buffer is supposed to work by default.

I'm using debian stretch at the moment. I don't necessarily need detailed answer, maybe a pointer to a correct log file etc. so I can solve issue myself. Thank you.
 
Old 07-13-2018, 05:41 AM   #2
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 3,448
Blog Entries: 3

Rep: Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524
It is working like it should and printing what it has received over to standard output (stdout). What are you trying to do with cat there?

With the way you are invoking it, you can exit with ctrl-d

Another way to invoke it would be with a Here Document which goes until it encouters a line starting with some designated text of your choosing:

Code:
 cat << END-OF-TEXT
> foo
> bar
> END-OF-TEXT
foo
bar
But both those ways only print to stdout and won't capture the output to a file.

Last edited by Turbocapitalist; 07-13-2018 at 05:42 AM.
 
Old 07-13-2018, 05:48 AM   #3
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
It is working like it should and printing what it has received over to standard output (stdout). What are you trying to do with cat there?

With the way you are invoking it, you can exit with ctrl-d

Another way to invoke it would be with a Here Document which goes until it encouters a line starting with some designated text of your choosing:

Code:
 cat << END-OF-TEXT
> foo
> bar
> END-OF-TEXT
foo
bar
But both those ways only print to stdout and won't capture the output to a file.
Actually now that I think about this more closely... It's a bit stupid. Basically I'm just trying to memorize basic commands/built-ins/programs etc. for now, so it's mostly playing around and tweaking stuff as I go. In this particular case I was just testing stuff while I ran into this.

My recollection of earlier times probably involved me putting output to some file. There it wouldn't do it the way it did now. But since there is no specified output it just echoes it immediately. Is this correct thinking?
 
Old 07-13-2018, 05:57 AM   #4
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 3,448
Blog Entries: 3

Rep: Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524
Quote:
Originally Posted by cuintilo View Post
My recollection of earlier times probably involved me putting output to some file. There it wouldn't do it the way it did now. But since there is no specified output it just echoes it immediately. Is this correct thinking?
Yes, you can use redirection (and more redirection info) to capture what you are entering.

Code:
$ cat > /tmp/cat.log.txt                                                
foo
bar
^d
$ cat /tmp/cat.log.txt                                                  
foo
bar
Or

Code:
$ cat << END-OF-TEXT > /tmp/cat.log.txt                                 
> foo
> bar
> END-OF-TEXT

$ cat /tmp/cat.log.txt                   
foo
bar
Understanding redirections is very useful. Memorizing programs isn't as much. You'll find yourself using the same ones often enough that you just start to remember them. For the rest, you'll known where and how to look up more information in the manual pages. Just-in-time rather than just-in-case knowledge inventory.

Code:
man cat
man man
 
1 members found this post helpful.
Old 07-13-2018, 06:47 AM   #5
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
Understanding redirections is very useful. Memorizing programs isn't as much.
Thank you for link, currently I'm reading "The Linux Command Line" by William Shots. Already went over first stuff about redirection in it but one you linked is more detailed. I'm only trying to do memorization for these basic things, I know that in time it would come by itself but I want to speed up the process a bit. Not going to memorize every single program/command, just ones that appear the most. Should I mark this thread as "solved"? I don't know if my post was really an issue anyway, but at least I find that I got useful information.
 
Old 07-13-2018, 07:22 AM   #6
Turbocapitalist
Senior Member
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 3,448
Blog Entries: 3

Rep: Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524Reputation: 1524
Quote:
Originally Posted by cuintilo View Post
Thank you for link, currently I'm reading "The Linux Command Line" by William Shots. Already went over first stuff about redirection in it but one you linked is more detailed. I'm only trying to do memorization for these basic things, I know that in time it would come by itself but I want to speed up the process a bit. Not going to memorize every single program/command, just ones that appear the most. Should I mark this thread as "solved"? I don't know if my post was really an issue anyway, but at least I find that I got useful information.
No problem. TLCL is a very useful book, probably parts 1 and 4 are the most useful once you start to find your way around. It's been a while since I've last read it but I recall that I liked part 4 because if you do something once, you'll probably do it again, and if you have done it several times it is a good candidate for automation.

In general if you approach this like learning any other programming language, it might help. The programs are like functions, more or less.

Other good bash resources would be Greg Wooldge's Guide, FAQ, and Pitfalls, as well as his programming guide:

https://mywiki.wooledge.org/BashGuide
https://mywiki.wooledge.org/BashFAQ
https://mywiki.wooledge.org/BashPitfalls
https://mywiki.wooledge.org/BashProgramming

Speaking of bash, a lot of GNU/Linux users refer to the shell and bash interchangeably but bash is just one shell of several good ones. zsh is another good and advanced shell. In that way it might be useful to try both bash and zsh so you can compare and contrast two advanced shells. POSIX shells like dash are nicer for scripting since they are both more portable and much faster.
 
1 members found this post helpful.
Old 07-13-2018, 07:44 AM   #7
cuintilo
LQ Newbie
 
Registered: Jun 2018
Distribution: Debian stretch
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
In general if you approach this like learning any other programming language, it might help. The programs are like functions, more or less.
I'm trying to use this approach. I'm still relatively new into more serious world of computers. I completed introductory cs-course on edX which was done using Python and I learned many basic concepts there. Haven't really managed to complete anything worthwhile yet, but I feel that after I switched my OS to Debian (used windows 7 before) I have much better flow to learning. Might be just that theres so much information coming in that even my brain can't ignore all of it - when I was trying to learn stuff on windows it pretty much started and ended with me opening and closing IDE, or at least that's how I felt.

I wish I could get into some sort of project to gather more experience but haven't had courage yet to try getting through for example at github. Would be glad to try and spot bugs or anything that would contribute to something... Giving me some new skills in the process of course.
 
  


Reply

Tags
buffer, cat


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
any cat people here ? one crazy cat s/woman/man/g here. ////// General 46 02-02-2018 11:13 AM
Why do os-prober and cat /etc/issue result in different outputs? pls_help_URGENT Linux - Newbie 10 04-14-2013 04:41 AM
difference :: cat file_1 & cat < f_1 tushar_pandey Linux - Newbie 4 08-16-2012 09:19 AM
cat /dev/tty issue m1organb Linux - Newbie 1 10-03-2011 08:20 PM

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

All times are GMT -5. The time now is 01:45 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration