Yes. There are several ways to delete two tab delimited fields from a file and modify the text in another field to contain the characters "AVIALABLE " (sic). Do you want to add the new text to the start of the old 5th field, to add the new text to the end of the old 5th field, or to replace the contents of the old 5th field with "AVIALABLE "?
Why do you want to use something other than awk for this? Is this a homework assignment that does not allow use of awk? (Oops, ignore that. I see that you have changed your requirements.)
Do you want to add AVAILABLE to the end of the 2nd field as in your code, or add "AVAILABLE " as requested in your description to what was in field 5 before you deleted fields 3 and 4?
Could you please try following and let me know if this helps.
Thanks,
R. Singh
Hi Ravinder,
Note that setting the 4th field to a backspace character does not remove the 4th field. Note also that if any of the fields contain spaces between words within the field, you need to set FS to tab as well as setting OFS to tab to get the proper output. For example, the command:
produces the output:
My interpretation of the request to "remove the column 3 and column 4 and insert a word in column 3" is different than yours. I thought it meant to delete fields 3 and 4 and modify the new 3rd field. You thought it meant to replace field 3 and delete field 4. And the code provided by the OP, added text to the end of the 2nd field, deleted the 3rd and 4th fields, and added a new empty field to the end of each line.
Until we get an unambiguous description of the desired processing, I don't know which interpretation is correct.
This User Gave Thanks to Don Cragun For This Post:
Hello,
I have some tab delimited files that may contain blank columns. I would like to delete the blank columns if they exist. There is no clear pattern for when a blank occurs.
I was thinking of using sed to replace instances of double tab with blank,
sed 's/\t\t//g'
All of the examples... (2 Replies)
Hi,
Can anyone please tell me about how we can delete an entire column from a tab delimited file?
Mu input_file.txt looks like this:
And I want the output as:
I used the below code
nawk -v d="1" 'BEGIN{FS=OFS="\t"}{$d=""}{print}' input_file.txtBut in the output, the first column is... (5 Replies)
I am fairly new to programming and trying to resolve this problem. I have the file like this.
CHROM POS REF ALT 10_sample.bam 11_sample.bam 12_sample.bam 13_sample.bam 14_sample.bam 15_sample.bam 16_sample.bam
tg93 77 T C T T T T T
tg93 79 ... (4 Replies)
Hello,
I have about 100 files in a directory with fields which are tab delimited. I would like to append the file name as the first field and it has to be done as many times as the total lines in the file.
For example,
myFile1.txt has the following data:
1 x y z
2 a b ... (5 Replies)
Hello,
Can someone help me to do this with awk or sed? I have a file with multiple lines, each line has many fields separated with a tab. I would like to add one more field holding 'na' in between the first and second fields.
old file looks like,
1, field1 field2 field3 ...
2, field1... (7 Replies)
I have a large text-file with tab-delimited genetic data that looks like:
KSC112 KSC234 0 0 1 1 A G C T
I simply wan to delete the first column, but since the file has 600 000 columns, it is not possible with awk (seems to be limited at 32k columns).
Does anyone have an idea how to do this? (2 Replies)
Hi
I have a txt file with 4 columns where I need to add 4 empty columns in the middle meaning that I need what is currently column 4 to be column 8 in a new file.
The idea is that I have to use the file as input in a program that reads the data in column 1 and 8, so the content of the other... (8 Replies)
I want to read only one column in "|" delimited file and write that column to a new file.
For Ex:
Input File
1|abc|324|tt
2|efd|11|cbcb
3||1|fg
4|ert|23|88
Output : I want to read column 3 in diff file.
324
11
1
88
Can anyone give me inputs on this ? (2 Replies)