pmpatrick Posted November 24, 2003 Report Share Posted November 24, 2003 When running a console in a gui I can run a series of commands with resulting ouput and if I want to save what I've done to a text file, I can highlight all the text I want to save with the mouse and copy it to a text file by creating an empty text file and copying with a wheel click. Is there any way to do this from a shell? For a single command I can redirect the output to a text file with ">" but I can't figure out how to select text from within a shell to save to a text file particularly when running a series of commands with output. Ideally, I'd like to know how to save the entire shell session to a text file for later review. I'm sure there's a way to do it; I just can't figure it out. Quote Link to comment Share on other sites More sharing options...
johnnyv Posted November 24, 2003 Report Share Posted November 24, 2003 http://docs.mandragor.org/files/Programmin..._en/x11830.html I know you can pipe your standard output & or standard error to a file but then i think it wont appear in the console which would be a problem. I don't know how to pipe to a file and still display in the console, but there are plenty here who are more experienced than me with bash so someone will know. Quote Link to comment Share on other sites More sharing options...
pmpatrick Posted November 25, 2003 Author Report Share Posted November 25, 2003 Thanks johnnyv but that's not what I'm looking for. That's just using "<" and ">" to redirect stdin or stdout from or to a text file. I don't know what I'm going to run in advace so I can't create a text file for stdin and ">" is limited to one command at a time and redirects the output to a text file and as you said you can't read the ouput on the screen. I was feeling pretty stupid for not knowing how to do this but maybe it's not as simple as I thought. Maybe some kind of screen capture could do it but that way seems like a real kludge and I'm not even sure it's possible. Quote Link to comment Share on other sites More sharing options...
johnnyv Posted November 25, 2003 Report Share Posted November 25, 2003 (edited) Well of course it will be possible! ;) had another look for you. try script man:/script in konq Edited November 25, 2003 by johnnyv Quote Link to comment Share on other sites More sharing options...
bvc Posted November 25, 2003 Report Share Posted November 25, 2003 I've heard something about editing the scripts/files (d/k which ones that would be) that open virtual consoles, or something, using the same '>' so that everytime that vt is opened the output is recorded to a 'specified in the script' file. Something to look into anyway. I d/k... inittab, or /etc/bashrc or both.....how about a console.perm file or whatever? Quote Link to comment Share on other sites More sharing options...
pmpatrick Posted November 25, 2003 Author Report Share Posted November 25, 2003 johnnyv, you da man Script is just what I was looking for. The only limitation I can see is that if you run something that ouputs formatted text in rows and columns like the "ls" command you get a bunch of garbage in your save text file, probably formatting metadata, but I can live with that. Thanks :D Quote Link to comment Share on other sites More sharing options...
johnnyv Posted November 26, 2003 Report Share Posted November 26, 2003 yes there is some junk but it is a limited set of junk have not seen more than 8 different occurances so you could just filter your text file to remove them. One thing you can't help is when you type a mistake the backspace to delete it and start again, script records all you typing, which can look odd. Quote Link to comment Share on other sites More sharing options...
spinynorman Posted November 26, 2003 Report Share Posted November 26, 2003 When you're in the shell, have you tried the 'save history as' option on the edit menu? It seems to fit the bill. :) Quote Link to comment Share on other sites More sharing options...
pmpatrick Posted November 26, 2003 Author Report Share Posted November 26, 2003 (edited) When you're in the shell, have you tried the 'save history as' option on the edit menu? You only get that in when running X with terminal emulators like konsole or xterm. Running from a shell is like booting to text mode or doing Ctrl-Alt-F1. There's no window with an edit menu; it's just you and the command prompt. Re the garbage appearing with script, I've only seen it with the ls command and the backspace problem you mentioned so far. I think the ls problem is related to the color coding on the ls output more than any thing else. Edited November 26, 2003 by pmpatrick Quote Link to comment Share on other sites More sharing options...
spinynorman Posted November 26, 2003 Report Share Posted November 26, 2003 (edited) I don't know how to pipe to a file and still display in the console, but there are plenty here who are more experienced than me with bash so someone will know. I'm not sure I qualify, but I have found the tee command, which does this. With the ls command, it strips out the colour on screen and in the file. ls -l | tee -a teefile This example also suppresses the wide format - ls ~ | tee -a teefile Just thought you'd like to know... Edited November 27, 2003 by spinynorman Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.