remove spaces in between file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers remove spaces in between file
# 1  
Old 10-19-2011
remove spaces in between file

hey,
I have this file:

Code:
ATOM   2510 HG12 VAL   160       8.462  15.861   1.637
ATOM   2511 HG13 VAL   160       9.152  14.510   0.725
ATOM   2512 CG2  VAL   160       6.506  16.579  -0.088
ATOM   2513 HG21 VAL   160       5.499  16.421  -0.478
ATOM   2514 HG22 VAL   160       6.417  16.984   0.920
ATOM   2515 HG23 VAL   160       7.032  17.294  -0.721
ATOM   2516 C    VAL   160       7.872  13.131  -1.419
ATOM   2517 O    VAL   160       8.337  12.679  -2.487
ATOM   2518 OXT  VAL   160       7.646  12.461  -0.386
TER 
ATOM   2519 N    VAL   161     -14.431   5.789 -25.371
ATOM   2520 H1   VAL   161     -15.336   5.698 -25.811
ATOM   2521 H2   VAL   161     -13.730   5.341 -25.946
ATOM   2522 H3   VAL   161     -14.202   6.769 -25.271
ATOM   2523 CA   VAL   161     -14.460   5.150 -24.037
ATOM   2524 HA   VAL   161     -13.436   4.844 -23.821
ATOM   2525 CB   VAL   161     -14.865   6.136 -22.897
ATOM   2526 HB   VAL   161     -15.820   5.852 -22.458
ATOM   2527 CG1  VAL   161     -13.804   6.048 -21.790


I have to remove "TER" and make the next line continous. Like this:
Code:
ATOM   2510 HG12 VAL   160       8.462  15.861   1.637
ATOM   2511 HG13 VAL   160       9.152  14.510   0.725
ATOM   2512 CG2  VAL   160       6.506  16.579  -0.088
ATOM   2513 HG21 VAL   160       5.499  16.421  -0.478
ATOM   2514 HG22 VAL   160       6.417  16.984   0.920
ATOM   2515 HG23 VAL   160       7.032  17.294  -0.721
ATOM   2516 C    VAL   160       7.872  13.131  -1.419
ATOM   2517 O    VAL   160       8.337  12.679  -2.487
ATOM   2518 OXT  VAL   160       7.646  12.461  -0.386
ATOM   2519 N    VAL   161     -14.431   5.789 -25.371
ATOM   2520 H1   VAL   161     -15.336   5.698 -25.811
ATOM   2521 H2   VAL   161     -13.730   5.341 -25.946
ATOM   2522 H3   VAL   161     -14.202   6.769 -25.271
ATOM   2523 CA   VAL   161     -14.460   5.150 -24.037
ATOM   2524 HA   VAL   161     -13.436   4.844 -23.821
ATOM   2525 CB   VAL   161     -14.865   6.136 -22.897
ATOM   2526 HB   VAL   161     -15.820   5.852 -22.458
ATOM   2527 CG1  VAL   161     -13.804   6.048 -21.790

sed can replace ter with a space but how to remove that space Smiliethen?...thanks

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by radoulov; 10-19-2011 at 08:12 AM..
# 2  
Old 10-19-2011
Code:
 
grep -v "^TER" inputfile > outputfile

# 3  
Old 10-19-2011
Code:
grep -v '^TER' file > newfile
#or
sed '/^TER/d' file > newfile

# 4  
Old 10-19-2011
This doesnot work...Space is still there
# 5  
Old 10-19-2011
This means ?
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to remove spaces and mv a file

I've tried various solutions to move a file name with spaces and nothing seems to work. I need to take a date as input, prepend it to a filename with spaces then remove the spaces and mv the file to the new name. #!/bin/ksh # if (( $# != 1 )) then echo "Usage: `basename $0` <DATE> " ... (5 Replies)
Discussion started by: w_s_s
5 Replies

2. Shell Programming and Scripting

Remove spaces from the file

Hi All, The output file contains data as below. "20141023","CUSTOMER" ,"COMPANY" ,"IN0515461" ,"" ,"JOSHUA" There are spaces in between the ending " and ,. The number of spaces is random. How can I remove that from the file so that the final output is:... (4 Replies)
Discussion started by: aarsh.dave
4 Replies

3. Shell Programming and Scripting

How to remove spaces from a file selectively?

Hi i have a file in which i am doing some processing. The code is as follows: #!/bin/ksh grep DATA File1.txt >> File2.txt sed 's/DATA//' File2.txt | tr -d ‘ ‘ >> File4.xls As you can see my output is going in a xl file.The output consist of four columns/feilds out of which the first... (20 Replies)
Discussion started by: Sharma331
20 Replies

4. Shell Programming and Scripting

Remove spaces in a file

Hi friends, I have a file1.txt 1 | a | 4757634 | jund jdkj | erhyj 2 | a | 4757634 | jnd jdkj | rhje hjrhwj i have used tr -d '\040' to remove the spcaes output file cat file1.txt | tr -d '\040' 1|a|4757634|jundjdkj|erhyj... (5 Replies)
Discussion started by: i150371485
5 Replies

5. Shell Programming and Scripting

How to remove all blank spaces in a file

I have a file which contains data such as that shown below. How do i remove all the blcnak spaces, before, during and at the end of each line in one command? 300015, 58.0823212, 230.424728 300016, 58.2276459, 229.141602 300017, 58.7590027, 226.960846 ... (9 Replies)
Discussion started by: carlr
9 Replies

6. Linux

How to remove spaces in the file?

hiii i have a file that contains spaces in the begining of a file till the middle the from there the txt would appear. hw can i remove those spaces and bring the text to the begining portion file1 text starts from here (12 Replies)
Discussion started by: anurupa777
12 Replies

7. Shell Programming and Scripting

how to remove blank spaces in file

hi i have a file which store some data.the contents of my file is data1:data2 data3:data4 i have a script which read this file correct="$(cat /root/sh | cut -d: -f1)" i used this syntax..please help me which syntax is used to remove blank spaces..then how to read this file.. (1 Reply)
Discussion started by: shubhig15
1 Replies

8. Shell Programming and Scripting

Remove trailing spaces from file

I'm currently writing my sql results to a file and they have trailing spaces after each field. I want to get rid of these spaces and I'm using this code: TVXTEMP=$(echo $TVXTEMP|sed -e 's/\ //g') It doesn't work though. I'm not familiar with sedscript, and the other codes I've found online... (6 Replies)
Discussion started by: avillanueva
6 Replies

9. Shell Programming and Scripting

Remove spaces between file names

Hi All, I have spaces in between file names. "Material Header.txt" "Customer Header.txt" "Vendor Header.txt" And how can I remove spaces between file names like below MaterialHeader.txt CustomerHeader.txt VendorHeader.txt Thanks Srimitta (10 Replies)
Discussion started by: srimitta
10 Replies

10. Shell Programming and Scripting

How can i remove spaces in between the fields in a file

Hey , I have a file and it's having spaces for some of the fields in it. Like the one below. I want to remove the spaces in them through out the file. The spaces occur randomly and i can't say which field is having space. So please help. Here is sample file with spaces after 5th field. (3 Replies)
Discussion started by: dsravan
3 Replies
Login or Register to Ask a Question