How to avoid the spaces?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to avoid the spaces?
# 1  
Old 09-25-2014
How to avoid the spaces?

Hi I have a script which runs the isql command and takes the output in a xls file.
Is there a way to trim the spaces(leading and trailing) from all the values in the column of the xls sheet?
# 2  
Old 09-25-2014
Please post sample input, expected output and tell us what you have tried so far.
# 3  
Old 09-25-2014
Here is the code


Code:
echo "use ex_abc\ngo\n SELECT 'Akanksha','    ',
   audit.req_strt_dtm as 'Access Datetime','        ', 
        audit.clm_id as 'ID',' ',
        audit.req_ext_usr_id as 'LDAP User ID','  ',
        clm.num as 'Number' 
    from
    ex_abc..ex_t audit,
    ex_abc..ex_n_t clm
    \ngo" > $sql

echo "  Access Datetime \t  ID \t LDAP User ID \t Number \t " > $outputFile

isql -U$SYBASE_USER -P$SYBASE_PW -S$SYBASE_SERVER -i$sql  -w2000 -o$tempsql

grep Akanksha $tempsql >> $tempsql1

sed s/DATA// $tempsql1 >> $outputFile

In this the outputFile has 4 columns and i am getting some space in the LDAP User ID section due to which my job is failing....

I want to remove the space and make sure that the data in the column is without any leading or trailing spaces.
# 4  
Old 09-25-2014
Cant you use one of the SQL string functions within Sybase to squeeze out the whitespace before dumping it out to a file...
# 5  
Old 09-25-2014
It would be helpful to see that actual output. I had an issue with mySQL and Oracle heterogenous Gateway a couple years ago. Every table that was stored as a double byte unicode character displayed as "A " or the character with a trailing space.

I could not figure it out, and eventually the customer upgraded their server from Redhat 5.7 to Redhat 6.3, so I set it up with the 6.3 ODBC driver and it worked fine. In my case I had an issue with the Redhat 5 ODBC driver and it worked fine in Redhat 6.
# 6  
Old 09-25-2014
Try resetting the COLSEP char...
# 7  
Old 09-26-2014
Quote:
Originally Posted by RudiC
Try resetting the COLSEP char...
How to do that?

---------- Post updated at 04:04 AM ---------- Previous update was at 04:02 AM ----------

By using LTRIM and RTRIM???
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to avoid the truncating of multiple spaces into a single space while reading a line from a file?

consider the small piece of code while read line do echo $line done < example content of example file sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the output is like sadasdasdasdsa erwerewrwr ergdgdfgf rgerg erwererwr the... (4 Replies)
Discussion started by: Kesavan
4 Replies

2. Solaris

Any way to avoid these errors?

Hello, this is solaris 10 on SF v440, I know below errors might go away if I put a new PS or put the original one back in socket but is there any other way to stop these errors from appearing in /var/adm/messages ? I do not want to put the failed PS1 in socket neither do we want to spend on... (5 Replies)
Discussion started by: upengan78
5 Replies

3. Shell Programming and Scripting

Removing blank spaces, tab spaces from file

Hello All, I am trying to remove all tabspaces and all blankspaces from my file using sed & awk, but not getting proper code. Please help me out. My file is like this (<b> means one blank space, <t> means one tab space)- $ cat file NARESH<b><b><b>KUMAR<t><t>PRADHAN... (3 Replies)
Discussion started by: NARESH1302
3 Replies

4. Shell Programming and Scripting

How to avoid CR after compression

Hi all, I am having few files which needs to be concted into a single file and then it is compressed and FTPed from the UNIX server to the Windows server. For the above purpose i am using gzip command to compress the files after concetenation. And i am FTP ing the compressed file in the... (3 Replies)
Discussion started by: Codesearcher
3 Replies

5. Shell Programming and Scripting

How to avoid the space

Hi, I have some problem with following command. $path='pwd'.”/pack”; When I check the value in the variable path , it give the following output /tmp/new /pack The pwd will be /tmp/new Now the problem is the spaces is added between pwd and the appended path. I need the output like... (5 Replies)
Discussion started by: kalpeer
5 Replies

6. UNIX for Dummies Questions & Answers

how to append spaces(say 10 spaces) at the end of each line based on the length of th

Hi, I have a problem where I need to append few spaces(say 10 spaces) for each line in a file whose length is say(100 chars) and others leave as it is. I tried to find the length of each line and then if the length is say 100 chars then tried to write those lines into another file and use a sed... (17 Replies)
Discussion started by: prathima
17 Replies

7. UNIX for Advanced & Expert Users

How to avoid polling???

Hi all, I have a directory where some process is keeping incremental/new log files. I need to code a program which will periodically poll this directory and if it founds a new file arrived then copy that new file to some other specific directory. We are OK with this polling approach. I just... (3 Replies)
Discussion started by: zing_foru
3 Replies

8. UNIX for Dummies Questions & Answers

echo is suppressing multiple spaces.How to avoid it

I am reading a file and copying selected lines from the file into another using echo. For eg: while read line do if ((some logic to determine whether I need to copy the current line to another file)) then echo $line > tempfile fi done<srcfile The problem I have is the data in the file... (1 Reply)
Discussion started by: prathima
1 Replies

9. Shell Programming and Scripting

Strip leading and trailing spaces only in a shell variable with embedded spaces

I am trying to strip all leading and trailing spaces of a shell variable using either awk or sed or any other utility, however unscuccessful and need your help. echo $SH_VAR | command_line Syntax. The SH_VAR contains embedded spaces which needs to be preserved. I need only for the leading and... (6 Replies)
Discussion started by: jerardfjay
6 Replies
Login or Register to Ask a Question