从Unix&QUOT输出格式;脚本"命令:删除退格,换行和删除字符? [英] format output from Unix "script" command: remove backspaces, linefeeds and deleted chars?

查看:330
本文介绍了从Unix&QUOT输出格式;脚本"命令:删除退格,换行和删除字符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用脚本来命令记录一个交互式shell会话,这样我可以用它来prepare文档。

I'm trying to use the script command to record an interactive shell session so that I can use it to prepare documentation.

脚本放置在日志文件中的一切,包括换行和结果
  退格。这不是天真的用户期望的结果。

Script places everything in the log file, including linefeeds and
backspaces. This is not what the naive user expects.

我是天真的用户(通常不会得到一个喊出来的手册页,这是非常令人兴奋的!),我想处理输出,使退格,换行和删除的字符等被删除

I am the naive user (don't usually get a shout out in man pages, this is rather exciting!), and I'd like to process the output so that backspaces, linefeeds and deleted characters and so on are removed.

例如,我跑的脚本的会话:

stew:~> script -f scriptsession.log
Script started, file is scriptsession.log
stew:~> date
Mon Aug 22 15:00:37 EDT 2011
stew:~> #extra chars: that
stew:~> exit
exit
Script done, file is scriptsession.log

然后我用的的阅读会话日志:

stew:~> cat scriptsession.log
Script started on Mon 22 Aug 2011 03:00:35 PM EDT
stew:~> date
Mon Aug 22 15:00:37 EDT 2011
stew:~> #extra chars: that
stew:~> exit
exit

Script done on Mon 22 Aug 2011 03:01:01 PM EDT

但是当我使用的的,我看到了不想要的字符是无形的使用证据的的:

but when I use less, I see evidence of the unwanted characters that are invisible using cat:

stew:~> less scriptsession.log
Script started on Mon 22 Aug 2011 03:00:35 PM EDT
stew:~> date
Mon Aug 22 15:00:37 EDT 2011
stew:~> #extra chars: thiESC[ESC[ESC[ESC[Kthat
stew:~> exit
exit

Script done on Mon 22 Aug 2011 03:01:01 PM EDT
scriptsession.log lines 1-8/8 (END)

当我使用的的,据我所知,它不删除无形的字符,它只是不可见的重新present他们一样的的呢 - 因此,如果我管的的输出到一个文件,它仍然有不想要的字符。

when I use cat, I understand that it doesn't remove the invisible chars, it just doesn't represent them visibly, like less does--so if I pipe the cat output to a file, it still has the unwanted characters.

我想要的输出格式是什么 显示复印。谢谢!

the output format I'd like is a copy of what cat displays. thanks!

(道歉,如果这是一个重复,搜索UNIX脚本输出格式返回大量噪音的结果相对于眼下的问题!)

(apologies if this is a duplicate, searching "unix script output format" returns lots of noise results with respect to the question at hand!)

推荐答案

山坳命令会做一些,但不是全部,过滤的你正在寻找。 (这似乎并不承认大胆并强调控制序列,例如。)

The col command will do some, but not all, of the filtering you're looking for. (It doesn't seem to recognize the control sequences for bold and underlining, for example.)

我已经在过去使用的一种方法是(一)改变我的shell提示符下,因此不会做任何高亮(它一般不会),和/或(b)设置 $ TERM 哑巴等等各种命令不会尝试使用某些控制序列。

An approach I've used in the past is to (a) change my shell prompt so it doesn't do any highlighting (it normally does), and/or (b) set $TERM to "dumb" so various commands won't try to use certain control sequences.

这篇关于从Unix&QUOT输出格式;脚本"命令:删除退格,换行和删除字符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆