Trimming the spaces


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Trimming the spaces
# 1  
Old 07-07-2008
Trimming the spaces

Hi,
How can I remove the unwanted spaces in the line.
123456 789 ABC DEF. - I wanna remove the sapces in this line, I need the output 123456789ABCDEF.

Pls help me......
# 2  
Old 07-07-2008
example:

Code:
echo "1 2 3 4 5" |tr -d [:SPACE:]


will do the trick

/peter

Last edited by radoulov; 07-07-2008 at 06:43 AM.. Reason: added code tags
# 3  
Old 07-07-2008
Code:
echo 123456 789 ABC DEF | sed "s/ //g"

This might help u!

Last edited by radoulov; 07-07-2008 at 06:43 AM.. Reason: added code tags
# 4  
Old 07-07-2008
Code:
$ str="123456 789 ABC DEF."
$ print ${str// /}
123456789ABCDEF.
$

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Trimming Spaces in Unix

Hi All, I am using following script to name the file base of some values #!/bin/sh sourcefile=$1 awk ' BEGIN{ n = 1; name = "FILEFILE12" n ".txt"; } { if (substr($0,1,10) == "FILEFILE12") { close (name) n++ a = substr($0,11,10); b = substr($0,21,5); name = b "_Src_" a ".txt" }... (6 Replies)
Discussion started by: manish8484
6 Replies

2. Shell Programming and Scripting

Trimming spaces from a variable

Hi guys, when I take substring of a particular data using this command var=substr($0,11,10) it comes with spaces, when I am trying to trim the spaces it is not allowing me to do that. Can you please help me out on that. As I have to reverse the output of the variable also. ---------- Post... (0 Replies)
Discussion started by: manish8484
0 Replies

3. Shell Programming and Scripting

How can I stop the unix script from trimming extra spaces?

I have a file which contains certain records about users. the row length is always fixed to 205 characters. Now I want to read each record line from the file, substring some portion out of it and put into another file. But I have observed that my script is trimming the extra spaces I have used for... (4 Replies)
Discussion started by: Pramit
4 Replies

4. Shell Programming and Scripting

trimming sequences

My file looks like this: But I would like to 'trim' all sequences to the same lenght 32 characters, keeping intact all the identifier (>GHXCZCC01AJ8CJ) Would it be possible to use awk to perform this task? (2 Replies)
Discussion started by: Xterra
2 Replies

5. Shell Programming and Scripting

Trimming output

I'm trying to parse an output log and I've managed to reduce the output to the lines I need. But I'm having trouble pulling out only the info I'm interested in. The output is 40+ lines and here is a sample Installing AppFresh 0.8.5.pkg from ./InstallerFiles/CustomPKG/26 (26) Installing... (2 Replies)
Discussion started by: kaltekar
2 Replies

6. Shell Programming and Scripting

trimming out spaces in solaris

friends, I have a script in solaris 10 SPARC system which is like this date '+Time: %m/%d/%y %H:%M:%S' echo " GDBRR GDLRR GDBWR GDLWR GDRRR GDRWR " sar -b 10 10 |/usr/xpg4/bin/awk '!/Average/ && !/SunOS/ && !/bread/ {$1="";T=$2;T1=$3;T2=$5;T3=$6;T4=$8;T5=$9}{print(T"\t",... (1 Reply)
Discussion started by: achak01
1 Replies

7. Shell Programming and Scripting

trimming lines

hi have output as i have trim of lines before CREATE statement and lins after last ")" any idea how to achieve it ? (3 Replies)
Discussion started by: crackthehit007
3 Replies

8. UNIX for Advanced & Expert Users

trimming zeros

Hi, I want to trim +with leading zero's with amount fields.I know using awk for trimming leading zeros with +,but I want get the entire row itself. cat file_name |awk -F " " '{printf "%14.4f%f\n",$4}' ex: 10 xyz bc +00000234.4500 20 yzx foxic +002456.000 Expexted 10 xyz bc... (3 Replies)
Discussion started by: mohan705
3 Replies

9. Shell Programming and Scripting

trimming white spaces

I have a variable that calls in a string from txt file. Problem is the string comes with an abundance of white spaces trailing it. Is there any easy way to trim the tailing white spaces off at the end? Thanks in advance. (9 Replies)
Discussion started by: briskbaby
9 Replies

10. Solaris

spaces trimming while assigning to a variable

Hi my lovely friends, Im writing one pgm in which i trying to assign some values like $var='Jun 6' but if i do echo of this $var will trim the spaces expect one space. $echo $var $Jun 6 But if var='Jun 28', then this will works fine $echo $var $Jun 28 this is required to exctract... (2 Replies)
Discussion started by: Lokesha
2 Replies
Login or Register to Ask a Question