LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 10-06-2004, 12:16 AM   #1
accent11
LQ Newbie
 
Registered: Oct 2004
Posts: 2

Rep: Reputation: 0
removing white space


i'm really new to bourne shell

the prob is that i'm trying to concatenate columns from a table to form a .sql filename

filename=$token1"_"$token2"_"$token3"_"$token4"_"$token5.sql

the output should be a_b_c_d_e.sql

but what appears instead is a_b_c_d_e .sql

how do i get rid of that space in between?
i'm really stumped (but that's probably cos of my lack of prog skill)
 
Old 10-06-2004, 12:25 AM   #2
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

What you're doing sounds perfectly reasonable: maybe "token5" has a space at the end?

Here's one workaround:

SQLFILE=`echo $token1 $token2 $token3 $token4 $token5 | awk '{print $1,$2,$3,$4,$5,'.sql'}'`

'Hope that helps .. PSM
 
Old 10-06-2004, 12:32 AM   #3
accent11
LQ Newbie
 
Registered: Oct 2004
Posts: 2

Original Poster
Rep: Reputation: 0
doesn't work. but thanks for the quick reply.

i've been at this for a while now and yet, still can't figure out what causes the space.

i looked at the source and the data type is varchar(2) so we know that can't be the cause.
 
Old 10-06-2004, 02:22 AM   #4
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

At the shell level, it should absolutely work.

What's this about "varchar(2)"? Could you give us a few more details about what you're doing?

thx in advance .. PSM
 
Old 10-06-2004, 02:30 AM   #5
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
One other suggestion: you can use "od -cx" to see what "hidden" characters might be in your string.

For example:

Code:
echo 'A C'|od -cx
0000000   A       C  \n
        2041 0a43
0000004
<= THIS EXAMPLE CREATES THE STRING WITH THE CHARACTERS 0x41 ('A'), 0x20 (' ') AND 0x43 ('C'), THEN PIPES TO "OD" TO ECHO THESE CHARACTERS IN HEX AND IN ASCII

But I'm definitely curious where these "tokens" are coming from in the first place (my previous question).

Thx in advance .. PSM
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
white space in eterm scrollback buffer asouldja Linux - Software 0 05-03-2005 07:49 AM
problems in removing white spaces from string of text monil Programming 7 03-08-2005 12:28 PM
KDE 3.3 and X.Org - Strange millimetre of white space under all windows StephenCM Linux - Software 0 01-14-2005 03:29 PM
striping white space and line blackzone Programming 2 11-22-2004 03:04 AM
Two Tuxes with block of white space??? robbow52 Debian 1 07-04-2004 02:05 PM


All times are GMT -5. The time now is 01:23 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration