help needed: remove space between certain columns


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help needed: remove space between certain columns
# 1  
Old 07-07-2011
help needed: remove space between certain columns

dear all,

i have a data looks like this (i have 3000 columns):
Code:
rs123 A T T G C C C C C C A A A A A A A A A A A ...
rs154 T T G C C C C C  A A A A A A A A A A T T G ...
rs126 A C C C C C A A A A A A A A A A A A T T G ...

I want to remove all the space after the 2nd column and make the data look like:
Code:
rs123 ATTGCCCCCCAAAAAAAAAAA ...
rs154 TTGCCCCCAAAAAAAAAATTG ...
rs126 ACCCCCAAAAAAAAAAATTG ...

if it is difficult to remove all the space after the 2nd column, it is also ok for me to remove all the space in the file and make the data look like:
Code:
rs123ATTGCCCCCCAAAAAAAAAAA ...
rs154TTGCCCCCAAAAAAAAAATTG ...
rs126ACCCCCAAAAAAAAAAATTG ...

anyone has code to do this? thanks in advance!

lin

Last edited by Franklin52; 07-07-2011 at 03:12 PM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 07-07-2011
One way, assuming you don't have a "#" sign in the 1st column:
Code:
sed 's/ /#/' file | tr -d " " | sed 's/#/ /'

# 3  
Old 07-07-2011
hi, i tried the code and it works. thanks a lot!
lin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help needed to create a UNIX Space monitoring script

Hi All, Its urgent.. pls help me out.. I want to create a KSH which should generate a report with the list of users and the files larger than 5 GB created by them in a direcorty and send autogenerated e-mail to them. my input would be users list,directory path and the file size (say 5 GB) ... (11 Replies)
Discussion started by: anman0523
11 Replies

2. UNIX for Advanced & Expert Users

Need to remove leading space from awk statement space from calculation

I created a awk state to calculate the number of success however when the query runs it has a leading zero. Any ideas on how to remove the leading zero from the calculation? Here is my query: cat myfile.log | grep | awk '{print $2,$3,$7,$11,$15,$19,$23,$27,$31,$35($19/$15*100)}' 02:00:00... (1 Reply)
Discussion started by: bizomb
1 Replies

3. Shell Programming and Scripting

Columns to rows with space

Hi, My input is in the following way a b c d e f I would like to have it printed as a b c d e f Any awk scripts are appreciated. (1 Reply)
Discussion started by: jacobs.smith
1 Replies

4. Shell Programming and Scripting

remove white space from specific columns in text file

Hello i have a text file like this: 1 AB AC AD EE 2 WE TR YT WW 3 AS UY RF YT the file is bigger , but that's an example of the data what i want to do is to merge all columns together except the first one, it will become like this : 1 ABACADEE 2 WETRYTWW 3 ASUYRFYT (8 Replies)
Discussion started by: shelladdict
8 Replies

5. UNIX for Dummies Questions & Answers

Help needed sorting syslog columns

Hi all, I need your help in sorting some columns in a syslog report. The command is: for messages in `cat syslog_message_list.txt`; do grep $messages syslog.`date +%d%m%y`.log | \ tr -s " " | cut -d" " -f4,9- | sort| uniq -c >> syslog.`date +%d%m%y`.report; done The output is: 1... (4 Replies)
Discussion started by: wthomas
4 Replies

6. Shell Programming and Scripting

Single command for add 2 columns and remove 2 columns in unix/performance tuning

Hi all, I have created a script which adding two columns and removing two columns for all files. Filename: Cust_information_1200_201010.txt Source Data: "1","Cust information","123","106001","street","1-203 high street" "1","Cust information","124","105001","street","1-203 high street" ... (0 Replies)
Discussion started by: onesuri
0 Replies

7. Shell Programming and Scripting

help with delimiting columns with a space

Hi all, i am writting a script to fix some problems we have with data that we need that contains 1000s of records. I have a text file with 3 columns of data. The problem is there should be a space between the end of the first column and the start of the second column. The majority of the data is... (7 Replies)
Discussion started by: borderblaster
7 Replies

8. AIX

How much space is needed by /usr?

Aix 5.2 If you install Aix and accept the default settings for the various filesystems how much space is allocated for /usr? I've just accepted the default settings for the install prompts and no third party apps have been installed. TIA (3 Replies)
Discussion started by: Westy564
3 Replies

9. UNIX for Dummies Questions & Answers

Help needed to sort multiple columns in one file

Hi, I would like to know given that I have 3 columns. Let say I have first 3 columns to do operation and these operation output is printed out each line by line using AWK and associative array.Currently in the output file, I do a sort by -r for the operation output. The problem comes to... (1 Reply)
Discussion started by: ahjiefreak
1 Replies

10. Shell Programming and Scripting

Trying to space columns in a report

I have a program that calculates shipping cost for an item and prints the information to a file. I cannot seem to get the lines to print with equal spacing in columns. I need data like this to be aligned into columns: Optical Mouse 5 A $25 Compaq Presario 3... (2 Replies)
Discussion started by: turbulence
2 Replies
Login or Register to Ask a Question