]> git.nbdom.net Git - nb.git/commitdiff
dbq option cut, LESS nor more break eof
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 22 Mar 2016 23:33:06 +0000 (23:33 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Tue, 22 Mar 2016 23:33:06 +0000 (23:33 +0000)
bin/dbq
etc/profile.d/envs

diff --git a/bin/dbq b/bin/dbq
index f19079ed6d7aa3dadbadacf8b3bebed764894edc..2e42c61e843c14e66cf7c657bbe6f2b6d4dc92f5 100755 (executable)
--- a/bin/dbq
+++ b/bin/dbq
@@ -155,7 +155,12 @@ $keys{table} = $1 if $keys{db} and $keys{db} =~ s/:(.*)$//;
 #
 # Parser
 #
-if ($keys{format} eq 'nc') {
+if ( $Opt{cut} ) {
+  open(STDOUT,"|cut -f $Opt{cut}");
+  $keys{format} = 'csv';
+  $keys{header} = '0';
+
+} elsif ($keys{format} eq 'nc') {
   $keys{format} = 'csv';
   open(STDOUT,"|$0 --parse_debug|$0 --csv2txt ".( ( defined($keys{header}) ? $keys{header} : '') eq '0' ? '1' : '0'))
 
@@ -428,6 +433,7 @@ Curl / Php query wrapper
 
 =head1 OPTIONS
 
+ option[cut=s]      Parse output to cut, imply format=csv and header=0
  option[ssh=s]      SERVER Run the script on that server
  option[verbose|v+] Verbose mode: increase the verbosity level.
  option[debug+]     Debug mode: increase the verbosity level.
index 7f02f85c5c527bb8709f8066a845917f9063ee87..f251393190bf3e94e507420c5ba8412b5a565c7c 100644 (file)
@@ -41,7 +41,7 @@ export PATH
 
 export IGNOREEOF=0
 export LESS="-iMR"
-export PAGER="less -iMRE"
+export PAGER="less $LESS"
 export EDITOR=vim
 case "$OSTYPE" in darwin*) export DARWIN=1;; esac