1

I am currently trying to find a way to redirect the standard output from beeline shell to text file without the grid. The biggest problem I am facing right now is that my columns have negative values and when I'm using regex to remove the '-', it is affecting the column values.

+-------------------+
|       col         |
+-------------------+
| -100              |
|  22               |
| -120              |
| -190              |
| -800              |
+-------------------+

Here's what I'm doing:

beeline -u jdbc:hive2://localhost:10000/default \
  -e "SELECT * FROM $db.$tbl;" | sed 's/\+//g' | sed 's/\-//g' | sed 's/\|//g' > table.txt

I am trying to clean this file so I can read all the data into a variable.

Vin
  • 177
  • 3
  • 11

1 Answers1

1

Assumming all your data has the same pattern , where no significant '-' are wrapped in '+' :

[root@machine]# cat boo
+-------------------+
|       col         |
+-------------------+
| -100              |
|  22               |
| -120              |
| -190              |
| -800              |
+-------------------+

[root@machine]# cat boo |  sed 's/\+-*+//g' | sed 's/\--//g' | sed 's/|//g'

       col

 -100
  22
 -120
 -190
 -800

confused genius
  • 2,876
  • 2
  • 16
  • 29