FS did not show after delete one field in awk


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting FS did not show after delete one field in awk
# 1  
Old 01-28-2011
FS did not show after delete one field in awk

Hello,
I met a problem to delete one column out of 32, say column 13. I tried awk and gawk but neither worked. The problem is col13 can deleted but the field separator is gone too, so that the output is not in tab-delimited format. Or, col13 can't be deleted. I want the output file with TAB as field separator. Any clue is appreciated.

Here is my script:

Code:
awk 'BEGIN { FS = "\t" } { $13=""; print}' file.tab

#This one deleted col13, but the FS is gone too making the output messed up

Code:
gawk -FS"\t" '($13="")13' file.tab

# This did not work as column 13 is still there although TAB is right
I am using Ubuntu 10.04 (Lucid)

Here is the first three rows of my file to be trimmed
==============================================
Code:
Run    NewProbeID    ProbeName    TargetID    Accessions    Description    FEATURES    FeatureNum    Row    Col    SubTypeMask    ControlType    ProbeName    SystematicName    PositionX    PositionY    gProcessedSignal    gProcessedSigError    gMedianSignal    gBGMedianSignal    gBGPixSDev    gIsSaturated    gIsFeatNonUnifOL    gIsBGNonUnifOL    gIsFeatPopnOL    gIsBGPopnOL    IsManualFlag    gBGSubSignal    gIsPosAndSignif    gIsWellAboveBG    SpotExtentX    gBGMeanSignal
1    GS000001    GT_Specific_Arabidopsis-SS-AT1G01073.1|35|60    AT1G01073.1    AT1G01073.1    Next best hit: CTGSIN-CL5216Contig2 Identity: 100.00 Alignment Length: 16 Annotation:  unknown protein    DATA    134077    789    117    0    0    GT_Specific_Arabidopsis-SS-AT1G01073.1|35|60    Arabidopsis-AT1G01073.1    3041.22    5206.48    2.64E+00    2.67E+00    38    33    8.75E+00    0    0    0    0    0    0    2.41979    0    0    27.0811    33.7054
2    GS000002    GT_Specific_Arabidopsis-SS-AT1G01100.1|468|60    AT1G01100.1    AT1G01100.1    Next best hit: SUPCTG-SuperContig_CL125Contig1 Identity: 100.00 Alignment Length: 17 Annotation:  60S acidic ribosomal protein P1 (RPP1A)    DATA    128355    756    5    0    0    GT_Specific_Arabidopsis-SS-AT1G01100.1|468|60    Arabidopsis-AT1G01100.1    682    5003.5    2.64E+00    2.66E+00    34    36    1.00E+01    0    0    0    0    0    0    0.0056826    0    0    26.2212    35.5756

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

Last edited by vgersh99; 01-28-2011 at 05:43 PM.. Reason: code tags, please!
# 2  
Old 01-28-2011
Code:
awk 'BEGIN { FS=OFS="\t" } { $13=""; sub(FS FS FS "*",FS)}1' file.tab

This User Gave Thanks to vgersh99 For This Post:
# 3  
Old 01-29-2011
Default FS has already included both space and tab.

Code:
gawk '{$13=""}1' OFS="\t" file.tab

# 4  
Old 01-29-2011
Quote:
Originally Posted by rdcwayx
Default FS has already included both space and tab.

Code:
gawk '{$13=""}1' OFS="\t" file.tab

Exactly- so having the embedded spaces in the tab separated fields will not fly.
Plus, the above will leave extra FS in place of the deleted field.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Problem with getting awk to multiply a field by a value set based on condition of another field

Hi, So awk is driving me crazy on this one. I have searched everywhere and read man, docs and every related post Google can find and still no luck. The actual files I need to run this on are sensitive in nature, but it is the same thing as if I needed to calculate weighted grades for multiple... (15 Replies)
Discussion started by: cotilloe
15 Replies

2. Shell Programming and Scripting

awk to update field using matching value in file1 and substring in field in file2

In the awk below I am trying to set/update the value of $14 in file2 in bold, using the matching NM_ in $12 or $9 in file2 with the NM_ in $2 of file1. The lengths of $9 and $12 can be variable but what is consistent is the start pattern will always be NM_ and the end pattern is always ;... (2 Replies)
Discussion started by: cmccabe
2 Replies

3. Shell Programming and Scripting

awk to adjust coordinates in field based on sequential numbers in another field

I am trying to output a tab-delimited result that uses the data from a tab-delimited file to combine and subtract specific lines. If $4 matches in each line then the first matching sequential $6 value is added to $2, unless the value is 1, then the original $2 is used (like in the case of line... (3 Replies)
Discussion started by: cmccabe
3 Replies

4. Shell Programming and Scripting

How can awk ignore the field delimiter like comma inside a field?

We have a csv file as mentioned below and the requirement is to change the date format in file as mentioned below. Current file (file.csv) ---------------------- empname,date_of_join,dept,date_of_resignation ram,08/09/2015,sales,21/06/2016 "akash,sahu",08/10/2015,IT,21/07/2016 ... (6 Replies)
Discussion started by: gopal.biswal
6 Replies

5. Shell Programming and Scripting

awk repeat one field at all lines and modify field repetitions

Hello experts I have a file with paragraphs begining with a keeping date and ending with "END": 20120301 num num John num num A keepnum1 num num kathrin num num A keepnum1 num num kathrin num num B keepnum2 num num Pete num num A keepnum1 num num Jacob num... (2 Replies)
Discussion started by: phaethon
2 Replies

6. Shell Programming and Scripting

Find and delete part of field with awk or sed

I've got a file that looks like this (the whitespace between commas is intentional): 123456789,12,JOHN H DOE ,DOE/JOHN H ,,,DOE/JOHN H ,,,,,123 FAKE STREET ,SPRINGFIELD,XX, I want to strip just the first name out of the third field so it reads "JOHN,". So far I... (6 Replies)
Discussion started by: Scottie1954
6 Replies

7. Shell Programming and Scripting

Delete all content in folder and not show any stderr/stdout

Hi i am a newbie, and have trying something that looked easy at first sight. in this script i want to delete all the files and directories in subdirectory1 (but not delete subdirectory1) and dont show any stderr or stdout messages: i try this but the stderr and stdout is shown...and it says... (2 Replies)
Discussion started by: bash100
2 Replies

8. Shell Programming and Scripting

awk - show field separator

I am using this code to insert something into a csv file: awk -F";" -v url=$url -v nr=$nr 'NR==nr{$2=url$2}1' file Why do I get the output field1 field2 instead of field1;field2 I have given -F";", so the field separator should surely be ";". (1 Reply)
Discussion started by: locoroco
1 Replies

9. Shell Programming and Scripting

AWK: Pattern match between 2 files, then compare a field in file1 as > or < field in file2

First, thanks for the help in previous posts... couldn't have gotten where I am now without it! So here is what I have, I use AWK to match $1 and $2 as 1 string in file1 to $1 and $2 as 1 string in file2. Now I'm wondering if I can extend this AWK command to incorporate the following: If $1... (4 Replies)
Discussion started by: right_coaster
4 Replies

10. Shell Programming and Scripting

awk, comma as field separator and text inside double quotes as a field.

Hi, all I need to get fields in a line that are separated by commas, some of the fields are enclosed with double quotes, and they are supposed to be treated as a single field even if there are commas inside the quotes. sample input: for this line, 5 fields are supposed to be extracted, they... (8 Replies)
Discussion started by: kevintse
8 Replies
Login or Register to Ask a Question