Insert space between two words


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Insert space between two words
# 1  
Old 01-14-2010
Insert space between two words

Hi,

I need to insert space between words on my output in UNIX other than the single space given by the space bar on my keyboard, e.g
Code:
when        are        you        going

. (There should be 4 spaces between each of these words)
rather than
Code:
when are you going

Can anyone help me with this?

Regards,

- diroro12 -

Last edited by Franklin52; 01-14-2010 at 10:21 AM.. Reason: Please use code tags!
# 2  
Old 01-14-2010
Code:
sp3="   "
a=A
b=B
echo "$a $sp $b"

works with sh and ksh and bash
# 3  
Old 01-14-2010
Thanks jgt.

- divroro12 -
# 4  
Old 01-14-2010
Code:
$ echo "when are you going" |  awk '$1=$1' OFS="    "
when    are    you    going

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Search and repllace of strings with space between words

Dear all, I have gone through all the search and replace requests but none of them meet my particular need. I have a huge file in which all Unicode characters are stored as Names. A sample is given below. I want to replace strings in that file with a mapper from another file termed as master.dic. ... (4 Replies)
Discussion started by: gimley
4 Replies

2. Shell Programming and Scripting

How to grep the words with space between?

see I have a text like: 27-MAY 14:00 4 aaa 5.30 0.01 27-MAY 14:00 3 aaa 0.85 0.00 27-MAY 14:00 2 aaa 1.09 0.00 27-MAY 14:00 5 aaa 0.03 0.00 27-MAY 14:00... (3 Replies)
Discussion started by: netbanker
3 Replies

3. UNIX for Dummies Questions & Answers

Vi - insert a tab between words?

I have several lines in a file that I want to replace a space with a tab. For example: 111047 Julie Jones email@email.com 111047 Julie Jones email@email.com I want to replace the space after the word "jones" with a tab. How do I achieve that in Vi? Please assist. Thanks! (5 Replies)
Discussion started by: onlinelearner02
5 Replies

4. Shell Programming and Scripting

how to insert space in alphanumeric string

Hi everyone, I want help to insert space between digits and letters in a alphanumeric string. INPUT TRY234TER PHY1TYR EXPECTED OUTPUT TRY 234 TER PHY 1 TYR The lines always begin with the letters and the alphabets will be a three letter combination before and after the number. The... (2 Replies)
Discussion started by: kaav06
2 Replies

5. UNIX for Advanced & Expert Users

Insert 1 space using the command sed

Hi I want to use sed to insert one space after the 10'th character in every line. The lines are on this format: 2012-01-1012:30:55|7323456|65432 2011-02-0313:11:06|1223|3456 ...... ...... Does anyone know sed well enough to acomplish this? If there is any other way around this... (7 Replies)
Discussion started by: ic12
7 Replies

6. Shell Programming and Scripting

Insert text space

I have the following texts in a .txt file, 22/02 23/02 24/02 25/02 26/02 Bike speed (kmph) 004 004 004 004 004 22/02 23/02 24/02 25/02 26/02 Bike speed (kmph) 004 007 007 007 011 I am trying to export it to .csv by doing cat nic.txt > nic.csv 22/02 23/02 are date and this has to... (7 Replies)
Discussion started by: nicolethomson
7 Replies

7. UNIX for Dummies Questions & Answers

insert white space between numbers

Hello all, I have a file with several lines like this: (1,1) (4,10) (8,23) (17, 4) (6,8) etc. and I need this: ( 1 , 1 ) ( 4 , 10 ) ( 8 , 23 ) ( 17 , 4 ) ( 6 , 8 ) How do I insert a space between the left parenthesis and the first number, between the first number and the comma,... (2 Replies)
Discussion started by: MDeBiasse
2 Replies

8. Red Hat

How to insert recursive words in a file on every line

Hi Guys, If someone can help me edit my script using sed or awk that will be great. I am trying to get a list of folders and their sizes upto 2 levels along with the week number by using following - (I am currently putting this information in a file and plan to run this script EVERY week) ... (1 Reply)
Discussion started by: rockf1bull
1 Replies

9. Shell Programming and Scripting

Insert varying length spaces between words

Hey all, Fist post, so be kind... I have written an expect script which logs into a terminal and gathers several screens of information. Unfortunately the log file gives me all the special escape and control characters from the terminal. I am hoping to use a combination of shell scripting, sed,... (1 Reply)
Discussion started by: mpacer
1 Replies

10. Shell Programming and Scripting

Remove all words after first space from each line

My file looks like: asd absjdd sdff vczxs wedssx c dasx ccc I need to keep asd sdff wedssx dasx How do I do that experts?:wall::wall: (1 Reply)
Discussion started by: hakermania
1 Replies
Login or Register to Ask a Question