Search Results

Search: Posts Made By: huiyee1
2,026
Posted By Scrutinizer
The gsub statement is just replacing and counting...
The gsub statement is just replacing and counting single letters, so it does not look at fields and whether the pattern is the entire field...

Try a loop instead:
awk 'BEGIN{print "count"}...
1,282
Posted By RudiC
Slight simplification:awk ' {printf...
Slight simplification:awk '
{printf "%s\t%s\t%s\t", $1, $2, $3
for (i=4; i<=NF; i+=2) {if ($i==$(i+1) || $(i+1) == "NN") printf "%s\t", $i
else ...
1,282
Posted By disedorgue
Hi, here a corrected version of your script: ...
Hi, here a corrected version of your script:
awk '{
printf("%s\t%s\t%s\t",$1,$2,$3)
for(i=4;i<=NF;i+=2){
if($i==$(i+1)) new=$i;
else if($i=="NN" || $(i+1)!="NN") new=$(i+1);
else...
2,644
Posted By Scrutinizer
Try: tr -s '\t' < file -- Note:...
Try:
tr -s '\t' < file



--
Note: RavinferSing13's suggestion works also, as long as there are no spaces somewhere in the input file, only TABS
2,644
Posted By RavinderSingh13
Hello huiyee1, Could you please try...
Hello huiyee1,

Could you please try following, it may help you.

awk '{$1=$1} 1' OFS="\t" Input_file


Output will be as follows.

LG10_PM_map_19_LEnd 1000560 G AG AG...
2,667
Posted By balajesuri
IMHO, awk seems to be the candidate for this job....
IMHO, awk seems to be the candidate for this job. Use awk to read the title and the next line (using getline function). If the 2nd line (fetched using getline) doesn't start with N, print title and...
2,083
Posted By anbu23
sed -n "/^@M/{N;p;}" file Or awk '...
sed -n "/^@M/{N;p;}" file

Or

awk ' /^@M/ { getline a; print $0 "\n" a } ' file
1,938
Posted By Yoda
awk 'NR%3' file
awk 'NR%3' file
1,938
Posted By Scrutinizer
sed 'n;n;d' file GNU sed: sed 0~3d file
sed 'n;n;d' file

GNU sed:
sed 0~3d file
2,617
Posted By RavinderSingh13
Hello All, Following may help too. ...
Hello All,

Following may help too.



awk '{for(i=1;i<=NF;i++) {if(i%2!=0) {a=a" "$i":"$(i+1)} else{if(i==NF) {print a;a=""} }}}' file_name



Output will be as follows.


1:0...
2,617
Posted By Franklin52
You can try something like: awk...
You can try something like:
awk '{for(i=1;i<=NF;i+=2)printf $i ":" $(i+1) FS}{print ""}' file
2,617
Posted By Subbeh
What doesn't work? It works with the sample you...
What doesn't work? It works with the sample you provided:
sed 's/\([0-9]\) \([0-9]\)/\1:\2/g' file
1:0 0:1 1:1
0:1 1:1 0:0
1:1 0:0 1:1
1:0 0:1 0:1
0:1 0:0 1:0
1:1 1:1 1:1
0:0 0:0 0:0

...
Showing results 1 to 12 of 12

 
All times are GMT -4. The time now is 12:38 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy