Replace space with empty


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Replace space with empty
# 1  
Old 11-14-2012
Replace space with empty

Hi All,

My Input is:
Code:
111.121 23212121
121.231 12678878

My output should be

Code:
111.12123212121
121.23112678878

in each row i need to replace that perticular space with empty.

8th position in the file for all rows.

Please help me in this case ..
Thanks

Last edited by Scrutinizer; 11-15-2012 at 01:45 AM.. Reason: code tags
# 2  
Old 11-15-2012
Try:

Code:
sed 's/ //' input-file >output-file

# 3  
Old 11-15-2012
replace space with empty

Thank you very much for u r reply,but here i need to replace perticular position with empty for all rows in the file.
Your code is not working according to my requirment,
Pls help me in this regard...
# 4  
Old 11-15-2012
Quote:
Originally Posted by raju4u
Thank you very much for u r reply,but here i need to replace perticular position with empty for all rows in the file.
Your code is not working according to my requirment,
Pls help me in this regard...
post some more examples. Agama solution will work for the posted example.
# 5  
Old 11-15-2012
Refer thread. I hope this helps.

---------- Post updated at 22:46 ---------- Previous update was at 22:42 ----------

Solution provided by balajesuri
Code:
sed 's/.//8' input_file

# 6  
Old 11-15-2012
Hi
Code:
111.121 23212121
121.231 12678878
112.231 12611117

In the above file 8th position is space and i need to replace with empty for that position for all rows.

Outpur should be like this:

Code:
111.12123212121
121.23112678878
112.23112611117


Last edited by Scrutinizer; 11-15-2012 at 01:48 AM.. Reason: code tags
# 7  
Old 11-15-2012
Code:
$ sed 's/.//8' a.txt
111.12123212121
121.23112678878
112.23112611117

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to check if the file is empty or has blank space.?

Hi, I am using KSH. I am trying to check if the output file is empty or not. I tried with ] but what i see is my file is empty but still manages to have a size of 1 instead of 0. But my file doesnot have anything its empty. I am not sure how to check this. can any one help? (10 Replies)
Discussion started by: Sharma331
10 Replies

2. Shell Programming and Scripting

Need command to replace empty using sed/awk

Hi, In a file we have the following data like as below abcdef="cfg-1-15" bmmdda-g-45-2 yhdiao"rtg-1-df-34" I need a sed/awk command to replace the above string with empty. Thx, (1 Reply)
Discussion started by: kirankumar
1 Replies

3. Shell Programming and Scripting

Add 0 values to replace empty value

Hi Guys. Please can you help me to add 0 values. Starting in column 121 Imput file A 4175.0 8055.01211 75 1 -2172671 77 45 16 457626.4 2609265.1 131.3 1090 102 1 1T N/A124 15 0.8 1051670971100000 A 4175.0 8055.012 7 75 2 -5204072 78 43 25... (10 Replies)
Discussion started by: jiam912
10 Replies

4. Shell Programming and Scripting

Replace empty string on particular column

Hi I would like to replace empty string with a particluar value, any suggessions with awk ? my input file is not delimited with any delimiters input 52001073M8000000004567777 5200107 000000004567778 5200107 000000004567779 52001073M8000000004567789 Expected output... (5 Replies)
Discussion started by: selvankj
5 Replies

5. Shell Programming and Scripting

Grep empty space and sort

Hi Expert, Kindly request for your expertise in this matter. I have below output: 12.125.124.173,xx1.common.com 12.125.124.174,xx2.common.com 12.125.124.175,xx3.common.com 12.125.124.176, 12.125.124.177, 12.125.124.178, 12.125.124.179,xx4.common.com 12.125.124.180,xx5.common.com... (8 Replies)
Discussion started by: regmaster
8 Replies

6. Shell Programming and Scripting

Replace all found files with an empty file?

Hi all, I need to replace certain robots.txt files with an empty file. I use the following to find the files I want to empty out: find /Sites -type f -name "robots.txt" -exec grep -il "STAGE" {} \; (finds all robots.txt files which contain the string 'STAGE') Now what do I add to this... (3 Replies)
Discussion started by: Evert
3 Replies

7. Shell Programming and Scripting

Replace long space to become one space?

Hi, i have the log attached. Actually i want the long space just become 1 space left like this : Rgds, (12 Replies)
Discussion started by: justbow
12 Replies

8. Shell Programming and Scripting

use awk to replace empty fields with the latest nonempty field

Hi suppose I have a csv file like this count,1977,1978,1979 usa, , , blue japan, red, yellow,green india, , yellow,blue china, blue, yellow, green I want the output to be(replace everything, including empty data, with the most recent data): ... (1 Reply)
Discussion started by: grossgermany
1 Replies

9. UNIX for Dummies Questions & Answers

Help required on printing the line if third field is not a empty space

Hi Experts, I want to print the lines whose third field in non-empty/blank space. i.e. INPUT FILE/B] dcdccghjrry0yd cont dcdccttrk820529 cont rdekedfsSCr dcdccttrdky2d0y cont rdekedfsSC2 ... (3 Replies)
Discussion started by: krao
3 Replies

10. Shell Programming and Scripting

empty space in java command through unix

I need to pass an empty space in the command ="java ......... " as one of the arguments where java calls some java command.... (It accepts it in windows as " ") Thanks in advance SD (2 Replies)
Discussion started by: shweta_d
2 Replies
Login or Register to Ask a Question