The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
trim fields using sed stonemonolith Shell Programming and Scripting 3 02-23-2009 04:16 PM
Trim inside awk subin_bala Shell Programming and Scripting 3 05-06-2008 08:51 AM
trim lines melanie_pfefer Shell Programming and Scripting 6 03-26-2008 07:25 AM
trim file tungaw2004 UNIX for Dummies Questions & Answers 1 09-15-2007 06:05 AM
Trim JWilliams Shell Programming and Scripting 4 04-24-2007 02:52 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-28-2008
scorpio scorpio is offline
Registered User
  
 

Join Date: Apr 2008
Posts: 41
Trim issue

Hi All,

I am using trim in my code..

ID_SA_SOURCE="`echo "$data" | cut -c17-34 | tr -s " "`"
ID_SA_DEST="`echo "$data" | cut -c35-52 | tr -s " "`"
echo"$ID_SA_SOURCE";"$ID_SA_DEST";

the output is

0608166896; 3001339; contains one whitespace between the two ..how can i remove that single white space ?

Thnks
  #2 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
tr -d instead of tr -s maybe? It's not really clear from your question where exactly that space is coming from.
  #3 (permalink)  
Old 04-28-2008
denn denn is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 96
agreed, it's very unclear what you're wanting to do..2 things however,
tr is "translate charachters" not trim!
the format you're using is not correct, you don't have double quotes formatted correctly."actually you don't have double-quotes.

Code:
tr -s " "`"  ## 3 quotes, not 4!
you also might want to use the ascii equiv to "`" char
or 
tr -s " " "\`"
  #4 (permalink)  
Old 04-28-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
Quote:
Originally Posted by denn View Post
Code:
tr -s " "`"  ## 3 quotes, not 4!
That's because that's inside backticks which are inside double quotes. The final double quote goes with the starting quote right before the starting backquote.
Sponsored Links
Closed Thread

Bookmarks

Tags
awk, awk trim, trim, trim awk

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 09:17 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0