Sponsored Content
Top Forums Shell Programming and Scripting Print Terminal Output Exactly how it Appears in the Terminal to a New Text File Post 302970099 by mrm5102 on Friday 1st of April 2016 06:52:18 PM
Old 04-01-2016
Hey guys, thanks for the replies. Much appreciated!

The sed command gave some strange results, and with the character locations not being preserved, I won't be able to find what I'm looking for in the file.

Thanks for the info on cat, but that just shows me what non-printing characters are in there and by removing the control chars it won't preserve how the text looks when printed using just 'cat filename.txt'....

I guess maybe this isn't possible..? I thought maybe it would be since the escape sequences are just re-arranging the text (*and inserting whitespace) and I can physically see how the formatted data SHOULD look when printed in the terminal. So I guess I kind of hoped I could just capture what is actually seen in the terminal and NOT what is unseen, like escape sequences/control-characters...

Thanks Again,
Matt

---------- Post updated at 06:52 PM ---------- Previous update was at 05:41 PM ----------

To explain a little better of what I'm trying to do see below, *maybe there is a simpler way....

So what the goal is, I'm trying get the output of the AIX command "topas" into a text file so I can grab one specific value... This command is very similar to the top command where it is an interactive command which just continuously updates the terminal window with new values every 2 seconds... Since it does that, that is why the control characters show up in the text file. They use the control characters to place the values correctly on the screen.

If you redirect topas to a text file and kill it right away, and then do a vi / view of the file the values are all over the place. It seems like it shows some of the Value's labels in the correct spot but their actual values could show up 20 lines below where it would be if you just did a 'cat' on the file.

I was praying topas had a command line switch similar to top's "-b" option for batch mode, but it does not...

There is a way to record the topas command's values with the topasrec command, but the output from that is harder to understand then just using topas. And I believe you need to use something like Excel to read that file....

I guess if there isn't another way I can just do what I'm already doing and see if that Label's value shows up on the exact same line everytime... If it does, I can just hard-code it in to capture that specific line and pull out the value... But, I guess we'll see.

Thanks Again,
Matt
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Output to terminal and file at the same time

Hi all The makefile of a large project produces hundreds of lines of output, which I can't look at any more when the build is finished. If I simply redirect the output to a file, I can't see the progress of the building process... Is there a possibility to redirect the output to a file and at... (1 Reply)
Discussion started by: Charlie
1 Replies

2. Solaris

terminal output - save to file?

I have a window open on my ultra 10 - a terminal window connecting to a server. Is there any way I can log all output to this window to a log file on my ultra 10 ? (2 Replies)
Discussion started by: frustrated1
2 Replies

3. UNIX for Advanced & Expert Users

Terminal Output to a File ??

Hey, How can I transfer the terminal output to a file ? For example : command "fuser" returns the "process-id" and prints the output on the terminal, but I want that output to a file as well. How can I do that ? /clocal/mqbrkrs/user/mqsiadm/sanjay/AccessMonitor $ fuser -uf... (2 Replies)
Discussion started by: varungupta
2 Replies

4. UNIX Desktop Questions & Answers

Output terminal sessions to screen and log file

I would like to use a terminal session to ssh to switches and routers. I need to capture data while logged into switches to a file I can email for troubleshooting. I use termial to log into Cisco switch, run the sh tech command, and then sent the output to cisco. Is there a way to run a... (4 Replies)
Discussion started by: tdelliott
4 Replies

5. UNIX for Dummies Questions & Answers

Live/real-time text-file updates in terminal

I want to have a terminal open and have something like a "repeating cat" command running in it for a certain text file (in particular /var/log/system.log). So my terminal will scan or cat the text file every so often or whenever the text file system.log gets written to by the system, it will... (1 Reply)
Discussion started by: guitarscn
1 Replies

6. Shell Programming and Scripting

how to Redirect the output of telnet command on a terminal to a file ?

(/home/user1)-> more script.sh #!/bin/ksh ( echo open devicename sleep 3; echo user; sleep 2; echo password; sleep 2; echo "/info/dump"; ---------> This needs to redirect to a file .Can be number of pages sleep 2; echo "exit" ) | telnet Please use code tags next time for... (2 Replies)
Discussion started by: necro98
2 Replies

7. UNIX for Dummies Questions & Answers

Strange behaviour when output to terminal vs file (awk)

Hi all ! I noticed something very weird. I have a large pipe delimited file (20 fields/3,000 records) that looks like that: AAA|BBB|11111|22222|...|($NF of record 1) CCC|DDD|33333|44444|...|($NF of record 2) CCC|DDD|55555|66666|...|($NF of record 3) For the lines with same 1st and 2nd... (3 Replies)
Discussion started by: beca123456
3 Replies

8. Shell Programming and Scripting

Printing Terminal Output to a Error File

I am having a bash script which is basically invoking a python program to validate the Source Query results against the target query results. I am placing all the queries in a .sql file. I want to write to a Error log file incase if the syntax is wrong or if the column is not present in the... (4 Replies)
Discussion started by: ronitreddy
4 Replies

9. Shell Programming and Scripting

Help needed editing text file using the terminal

Hi, I have text file with the header like this tracking_id condition replicate FPKM XLOC_000001 alpha 1 10.3199 XLOC_000001 alpha 0 10.3686 XLOC_000001 alpha 2 15.5619 ... With the first column being genes, the second being the condition, the third... (5 Replies)
Discussion started by: 4galaxy7
5 Replies

10. Shell Programming and Scripting

Cannot get terminal application to launch with a graphical launcher when successful in terminal

I have been having an extremely annoying problem. For the record, I am relatively new at this. I've only been working with unix-based OS's for roughly two years, mostly Xubuntu and some Kali. I am pretty familiar with the BASH language, as that's the default shell for debian. Now, I've made this... (16 Replies)
Discussion started by: Huitzilopochtli
16 Replies
more(1) 						      General Commands Manual							   more(1)

Name
       more, page - display file data at your terminal

Syntax
       more [-cdflsu] [-n] [+linenumber] [+/pattern] [name...]

       page more options

Description
       The  filter allows you to examine a file one screenful of text at a time on a soft-copy terminal.  It normally pauses after each screenful,
       printing --More-- at the bottom of the screen.  If the user then types a carriage return, one more line is displayed.  If the user  presses
       the space bar, another screenful is displayed.

Options
       +linenumber Start up at linenumber.

       +/pattern   Start up two lines before the line containing the regular expression pattern.  The command line options are:

       -c	   Begins  each  page at the top of the screen and erases each line just before it draws on it.  This avoids scrolling the screen,
		   making it easier to read while is writing.  This option is ignored if the terminal does not have the ability to  clear  to  the
		   end of a line.

       -d	   Displays  extended  continuation  prompt at end of each display.  The command prompts the user with the message "Press space to
		   continue, 'q' to quit." at the end of each screenful, and responds to subsequent illegal user input by printing "Press 'h'  for
		   instructions." instead of ringing the bell.	This is useful if more is being used as a filter in some setting, such as a class,
		   where many users may be unsophisticated.

       -f	   Counts logical text lines (does not fold long lines).  This option is recommended if output is being piped  through	since  the
		   latter  may	generate  escape  sequences.  These escape sequences contain characters which would ordinarily occupy screen posi-
		   tions, but which do not print when they are sent to the terminal as part of an escape sequence.  Thus may think that lines  are
		   longer than they actually are, and fold lines erroneously.

       -l	   Ignores  line feeds (CTRL/Ls) and normally, pauses at line feeds.  If this option is not given, pauses after any line that con-
		   tains a ^L, as if the end of a screenful had been reached.  Also, if a file begins with a form  feed,  the  screen  is  cleared
		   before the file is printed.

       -n	   Specifies number of line displays.

       -s	   Squeezes  multiple  blank  lines  from the output, producing only one blank line.  Especially helpful when viewing output, this
		   option maximizes the useful information present on the screen.

       -u	   Ignores all underlining in the data.  If the terminal can perform underlining or has  a  stand-out  mode,  outputs  appropriate
		   escape  sequences  to  enable  underlining or stand-out mode for underlined information in the source file.	The -u option sup-
		   presses this processing.

       If the program is invoked as page, then the screen is cleared before each screenful is printed (but only  if  a	full  screenful  is  being
       printed), and k - 1 rather than k - 2 lines are printed in each screenful, where k is the number of lines the terminal can display.

       The  command looks in the file /etc/termcap to determine terminal characteristics, and to determine the default window size.  On a terminal
       capable of displaying 24 lines, the default window size is 22 lines.

       The command looks in the environment variable MORE to pre-set any flags desired.  For example, if you prefer to view  files  using  the	-c
       mode  of  operation,  the  command  setenv MORE -c or the command sequence MORE='-c' ; export MORE would cause all invocations of including
       invocations by programs such as and to use this mode.  Normally, the user places the command sequence which sets up  the  MORE  environment
       variable in the .cshrc or .profile file.

       If  is  reading from a file, rather than a pipe, then a percentage is displayed along with the --More-- prompt.	This gives the fraction of
       the file (in characters, not lines) that has been read so far.

       Other sequences which may be typed when pauses, and their effects, are as follows (i is an optional integer argument, defaulting to 1) :

       i<space>    Display i more lines, (or another screenful if no argument is given)

       ^D	   Display 11 more lines (a ``scroll'').  If i is given, then the scroll size is set to i.

       d	   Same as ^D (control-D)

       iz	   Same as typing a space except that i, if present, becomes the new window size.

       is	   Skip i lines and print a screenful of lines

       if	   Skip i screenfuls and print a screenful of lines

       ib or i^B   Skip back i screenfuls and print a screenful of lines

       q or Q	   Exit from more.

       =	   Display the current line number.

       v	   Start up the editor at the current line.

       h or ?	   Help command; give a description of all the more commands.

       i/expr	   Search for the i-th occurrence of the regular expression expr.  If there are less than i occurrences of expr, and the input	is
		   a  file  (rather  than a pipe), then the position in the file remains unchanged.  Otherwise, a screenful is displayed, starting
		   two lines before the place where the expression was found.  The user's erase and kill characters may be used to edit the  regu-
		   lar expression.  Erasing back past the first column cancels the search command.  of the last regular expression entered.

       in	   Search for the i-th occurrence

       '	   (single  quote)  Go to the point from which the last search started.  If no search has been performed in the current file, this
		   command goes back to the beginning of the file.

       !command    Invoke a shell with command.  The characters `%' and `!' in "command" are replaced with the current file name and the  previous
		   shell  command  respectively.  If there is no current file name, `%' is not expanded.  The sequences "\%" and "!" are replaced
		   by "%" and "!" respectively.

       i:n	   skip to the i-th next file given in the command line (skips to last file if n doesn't make sense)

       i:p	   Skip to the i-th previous file given in the command line.  If this command is given in the middle of printing out a file,  then
		   goes  back to the beginning of the file. If i doesn't make sense, skips back to the first file.  If is not reading from a file,
		   the bell is rung and nothing else happens.

       :f	   Display the current file name and line number.

       :q or :Q    Exit from

       .	   (dot) Repeat the previous command.

       The commands take effect immediately, that is, it is not necessary to type a carriage return.  Up to the time when  the	command  character
       itself is given, the user may hit the line kill character to cancel the numerical argument being formed.  In addition, the user may hit the
       erase character to redisplay the --More--(xx%) message.

       At any time when output is being sent to the terminal, the user can hit the quit key (normally control-).  The command stops sending  out-
       put,  and displays the usual --More-- prompt.  The user may then enter one of the above commands in the normal manner.  Unfortunately, some
       output is lost when this is done, due to the fact that any characters waiting in the terminal's output queue are flushed when the quit sig-
       nal occurs.

       The  terminal  is set to noecho mode by this program so that the output can be continuous.  What you type not show on your terminal, except
       for the / and !	commands.

       If the standard output is not a teletype, then acts just like except that a header is printed before each file (if there is more than one).

       A sample usage of in previewing output would be
       nroff -ms doc.n | more -s

Files
       /etc/termcap	   Terminal data base
       /usr/lib/more.help  Help file

See Also
       csh(1), man(1), msgs(1), script(1), sh(1), environ(7)

																	   more(1)
All times are GMT -4. The time now is 02:36 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy