sql server - How can I insert newlines in the correct places in isql output in a bash script? -


I am using isql in a database (SQL Server) in a bash script. For example:

  RESULT = "$ ($ {ISQL} -Q -U $ {DB_USER} -S $ {DB_SERVER} -D $ {DB_NAME}  
  Mod5 count -------------------- ----------- 17640 1 17640 2 17638 3 17637 4 17638  

How do I get new lines in it? For example:

  mod5 count --------------------- ---------- 0 18118 1 18118 2 18116 3 18116 4 18117 I can do anything !!! And then '' !!! 'with a new line, but I still do not know what to do about the first two rows (headers and dashes) In this case, I know that I'm going to have two fields of output So, I can count some of the constraints and include new lines, but if I do not know how many columns will return in a query like "Select from the order"?  

I can think of various solutions but all of them are incredibly visible - is there a standard way of dealing with this kind of way?

isql or sql- There is no information about server but for your problem, it works Is:

 . Cmd ..gives..output | Xargs -n2  

with your data:

  Kent echo "count mod5 --------------- ----- ----------- 0 17640 1 17640 2 17638 3 17637 4 17638 "| Xgs-N2 mode 5 count -------------------- ----------- 17640 1 17640 2 17638 3 17637 4 17638  

Comments