首页 > Linux操作系统 > Linux操作系统 > [20190108]rlwrap sqlplus tee相关问题.txt

[20190108]rlwrap sqlplus tee相关问题.txt

原创 Linux操作系统 作者:lfree 时间:2019-01-08 16:53:53 0 删除 编辑

[20190108]rlwrap sqlplus tee相关问题.txt


rlwrap sqlplus scoott/book | tee -a aa.txt


--//向一些命令都有1个规避缓存的命令行参数.比如tcpdump 的-l参数,sed -u参数.



--//一些新版本linux版本的coreutils包里面包括一个命令stdbuf(Red Hat Enterprise Linux Server release 7.5就有这个命令)


$ rlwrap sqlplus sys as sysdba | stdbuf -i0 -o0 -e0 tee -a /tmp/aa.txt

$ rlwrap  sqlplus scott/book | unbuffer -p tee -a /tmp/aa.txt


# rlwrap -z listing

The following filters can be found in  /usr/local/share/rlwrap/filters

count_in_prompt                replace prompt by simple counter

ftp_filter                     run plain Netkit ftp with completion for commands, local and remote files

history_format                 Append <format> to every history item, and strip it off again when input is accepted

logger                         log messages to a file (for debugging)

null                           a filter that does nothing

paint_prompt                   paint the prompt in colour gradient between X11 colours <colour1> and <colour2>

pipeline                       combines the effects of 2 or more filters

pipeto                         Allow piping of <command> output through pagers or other shell commands

scrub_prompt                   removes all junk from prompt

simple_macro                   simple on-the-fly macro processing

template                       filter template

unbackspace                    remove backspaces from output



# cd /usr/local/share/rlwrap/filters

# vim outfilter

#! /usr/bin/perl

use lib ($ENV{RLWRAP_FILTERDIR} or ".");

use RlwrapFilter;

use strict;

my $filter = new RlwrapFilter;

my $name = $filter->name;

my $filter_command = join ' ', @ARGV;

$filter->help_text("Usage: rlwrap -z '$name <filter-command>' <command>\n"

                   . "Filter <command> output through <filter-command>");

$filter->output_handler(sub {""});



sub prompt {

    my $prompt = shift;

    my $output = $filter->cumulative_output;

    $output =~ s/\r//g;

    open (PIPE, "| $filter_command")

        or die "Failed to create pipe: $!";

    print PIPE $output;

    close PIPE;

    return $prompt;


# chmod 755  outfilter

$ rlwrap -z 'outfilter tee -a /tmp/aa.txt'  sqlplus scott/book




$ tail -f /tmp/aa.txt |grep -i SUPP

--//在终端1 sqlplus下执行:

SCOTT@book> @ desc v$database ;


   30      SUPPLEMENTAL_LOG_DATA_MIN                VARCHAR2(8)

   31      SUPPLEMENTAL_LOG_DATA_PK                 VARCHAR2(3)

   32      SUPPLEMENTAL_LOG_DATA_UI                 VARCHAR2(3)

   40      SUPPLEMENTAL_LOG_DATA_FK                 VARCHAR2(3)

   41      SUPPLEMENTAL_LOG_DATA_ALL                VARCHAR2(3)

   51      SUPPLEMENTAL_LOG_DATA_PL                 VARCHAR2(3)


$ tail -f /tmp/aa.txt |cut -d"|" -f1,2,30,31,32,40,41,51


SCOTT@book> set linesize 3000

SCOTT@book> set colsep |

SCOTT@book> select * from v$database ;




1337401710|BOOK                |NO      |NO |NO |NO |NO |NO


来自 “ ITPUB博客 ” ,链接:,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。


  • 博文量
  • 访问量