modify one column

Hi,

I have an output that looks unusual and it is very large so I cannot do it manually.

Basically it looks like this:

U	>c93[org=S_paradoxus][moltype=genomic][contig=c93]	57866	R
U	>c38[org=S_paradoxus][moltype=genomic][contig=c38]	66265	R
U	>c261[org=S_paradoxus][moltype=genomic][contig=c261]	80401	R
U	>c169[org=S_paradoxus][moltype=genomic][contig=c169]	12250	R
U	>c348[org=S_paradoxus][moltype=genomic][contig=c348]	2661	F
U	>c425[org=S_paradoxus][moltype=genomic][contig=c425]	38762	R
U	>c351[org=S_paradoxus][moltype=genomic][contig=c351]	44504	R
U	>c421[org=S_paradoxus][moltype=genomic][contig=c421]	8212	F
U	>c467[org=S_paradoxus][moltype=genomic][contig=c467]	3648	F
U	>c84[org=S_paradoxus][moltype=genomic][contig=c84]	33028	R
U	>c6[org=S_paradoxus][moltype=genomic][contig=c6]	4765	R

It is a tab separated file and I want it to modify the second column (basically simplify it) to look like this:

U	c93	57866	R
U	c38	66265	R
U	c261	80401	R
U	c169	12250	R
U	c348	2661	F
U	c425	38762	R
U	c351	44504	R
U	c421	8212	F
U	c467	3648	F
U	c84	33028	R
U	c6	4765	R

Thanks

Phil

sed 's/<tab>.*contig=\(.*\)]/<tab>\1/' inp_file

hi thanks for the post but it makes no change to the file.

$ sed "s/\([^>]*\).*=\([^]]*\)]/\1\2/" file
U	 c93	57866	R
U	 c38	66265	R
U	 c261	80401	R
U	 c169	12250	R
U	 c348	2661	F
U	 c425	38762	R
U	 c351	44504	R
U	 c421	8212	F
U	 c467	3648	F
U	 c84	33028	R
U	 c6	4765	R

awk -F"[\t>[]" '{print $1"\t"$3"\t"$(NF-1)"\t"$NF}'
awk '{split($2,a,"[>|[]");print $1,a[2],$3,$4}' OFS="\t" infile
 
sed 's/\>.*contig=//;s/]//g' infile
1 Like