No delete black spaces!


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting No delete black spaces!
# 1  
Old 10-04-2012
Data No delete black spaces!

Hi,

I have the next problem, i am triying to concatenate two variables with white spaces at the cornes, but the shell deletes them.

For example i have the next code:

A="Hello "
B="Hello"

echo $A$B

output: Hello Hello

You can see only one space between the words, and i put 5 space after the first "Hello".

How can i keep this spaces for cancatenate two words? SmilieSmilie

Thanks!

P.D. Sorry for my english, it is very bad.
# 2  
Old 10-04-2012
Code:
 
A="Hello      "
B="Hello"
echo "${A}${B}"
Hello      Hello


Last edited by rdrtx1; 10-04-2012 at 12:51 PM.. Reason: corrected for multiple spaces.
This User Gave Thanks to rdrtx1 For This Post:
# 3  
Old 10-04-2012
This page did to me the same problem ahaha white example code. I will put it again. Imagine the "_" is a simple space.

Code:
A="Hello     "
B="Hello"

echo $A$B

output:
Code:
Hello Hello

Moderator's Comments:
Mod Comment
Please use code tags when posting data and code samples!

Last edited by vgersh99; 10-04-2012 at 12:51 PM.. Reason: code tags, please!
# 4  
Old 10-04-2012
Code:
A="Hello     "
B="Hello"
echo "$A$B"

This User Gave Thanks to vgersh99 For This Post:
# 5  
Old 10-04-2012
In echo, to preserve white-space contained in the variable value, you need to enclose the variable evaluation in double quotes. Didn't you read what rdrtx1 suggested?
This User Gave Thanks to elixir_sinari For This Post:
# 6  
Old 10-04-2012
The problem is solved. Thank's everyone.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Delete line breaks and extra spaces between patterns

Hi, if in between strings "<section" and "</section>" across multiple lines there occurs the string "ole-present", delete all line breaks and replace any tabs or multiple spaces with a single space. Looking for an AWK or SED solution. Thank you. <section ... status = "ole-present" ...... (2 Replies)
Discussion started by: pioavi
2 Replies

2. Shell Programming and Scripting

sed delete leading spaces in a .csv if not in a string

Solaris, ksh I have a .csv file I am trying to clean up before loading into the database. The file contains comma separated columns that have leading spaces which I need to remove. The trouble is, some columns that should not be touched are strings which happen to have the same pattern in them. ... (4 Replies)
Discussion started by: gary_w
4 Replies

3. Shell Programming and Scripting

How to delete ending/trailing spaces using awk,sed,perl?

How to delete ending/trailing spaces using awk,sed,perl? Input:(each line has extra spaces at the end) 3456 565 3 7 35 878 Expected output: 3456 565 3 7 35 878 (5 Replies)
Discussion started by: cola
5 Replies

4. Shell Programming and Scripting

delete empty spaces at specific column

Hi All, If anybody could help me with my scenario here. I have a statement file. Example of some content: DATE DESC Debit Credit Total Rate 02-Jan-08 Lodgement 200.00 1200.00 2.51 14-Sep-07 Withdrawal 50.00 1000.00 ... (8 Replies)
Discussion started by: yonez
8 Replies

5. UNIX for Dummies Questions & Answers

want to remove " in a file and delete empty spaces

I have to remove character " in file which occurs at every line and have to delete empty spaces. Please help (2 Replies)
Discussion started by: vikram2008
2 Replies

6. UNIX for Dummies Questions & Answers

Delete Multiple White Spaces

Hi, I have a file that has multiple spaces between characters. I want to delete or convert the multiple spaces into a single space. I think this can be done in "sed" but I only know the syntax to delete trailing or leading spaces. Can this be done with "sed" or awk? I have a file that looks... (6 Replies)
Discussion started by: eja
6 Replies

7. UNIX for Dummies Questions & Answers

how to delete spaces around a word

suppose a line has one word ex: unix how to delete space around that word? (8 Replies)
Discussion started by: sachin.gangadha
8 Replies

8. Shell Programming and Scripting

delete spaces in the variable in unix script?

Hi All, I need your help.I want to know how to delete the spaces in a variable in unix scripting.Please give solution to this probelm... thanks ! :confused: (14 Replies)
Discussion started by: MARY76
14 Replies

9. Shell Programming and Scripting

Delete spaces in between fields

I am new to unix and need some assistance. I have a file in the format below with about 15 fields per each record. I have 2 records displayed below. "1234","Andy ","Rich ","0001","123 Main Street ","Dallas " "2345","Andrew ","Richter ","0002","234 First Ave ... (12 Replies)
Discussion started by: guiguy
12 Replies

10. Shell Programming and Scripting

delete white spaces

hi all... i have the next question: i have a flat file with a lot of records (lines). Each record has 10 fields, which are separated by pipe (|). My problem is what sometimes, in the first record, there are white spaces (no values, nothing) in the beginning of the record, like this: ws ws... (2 Replies)
Discussion started by: DebianJ
2 Replies
Login or Register to Ask a Question