bash 从 isql 输出中删除空格
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 
原文地址: http://stackoverflow.com/questions/14064433/
Warning: these are provided under cc-by-sa 4.0 license.  You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Remove white space from isql output
提问by bqui56
Is there any way to stop isqlfrom adding spacing before and after the returned fields? I just want the values from the table row separated by ,. At the moment, using -band -s ',', I get:
有什么办法可以阻止isql在返回字段前后添加间距?我只想要表格行中的值由,. 目前,使用-band -s ',',我得到:
,some_column_entry         ,          3213,            another_column_entry,
however, I want:
但是,我想要:
,some_column_entry,3212,another_column_entry,
I read through all the switches, but couldn't seem to find anything appropriate. My wish is to get isqlto output in this form rather than parsing the output.
我通读了所有的开关,但似乎找不到任何合适的东西。我希望以isql这种形式输出而不是解析输出。
EDIT:
编辑:
select top 1 rtrim(ltrim(some_column)) from table
returns
回报
,abc             ,
isqlseems to output based on the size of max characters, because if I run the following:
isql似乎根据最大字符的大小输出,因为如果我运行以下命令:
select top 1 rtrim(ltrim(convert(varchar(3), some_column)) from table
I get:
我得到:
,abc,
采纳答案by ???ěxě?
Try this
尝试这个
    Use RTRIM(LTRIM(ColumnName)) in your -q Query Select command.
回答by sampson-chen
The contrast between
之间的对比
some_column_entry         ,
and
和
,            another_column_entry,
leads me to think that the spaces are part of your field entries, as opposed to the delimiters used.
让我认为空格是您的字段条目的一部分,而不是使用的分隔符。
From man isql:
来自man isql:
-dx Delimit columns with x.
-x0xXX Delimit columns with XX, where XX is in hex. For example -x0x09 will use a tab.
-dx 用 x 分隔列。
-x0xXX 用 XX 分隔列,其中 XX 为十六进制。例如 -x0x09 将使用选项卡。
If that doesn't work, then you can pipe the output of isqlthrough a simple seduse case:
如果这不起作用,那么您可以isql通过一个简单的sed用例来传输输出:
isql ... | sed -e 's/\ //g'

