Search Results

Search: Posts Made By: evelibertine
1,401
Posted By bartus11
Try:awk '{for (i=2;i<=NF;i+=3) printf...
Try:awk '{for (i=2;i<=NF;i+=3) printf ($i+$(i+1))/2" ";printf "\n"}' file
4,710
Posted By rdrtx1
try: awk '$2 == "NA" {$2=$1":"$4} 1' OFS="\t"...
try:
awk '$2 == "NA" {$2=$1":"$4} 1' OFS="\t" infile
1,436
Posted By hiten.r.chauhan
Just enclose the file name variable in double...
Just enclose the file name variable in double quotes as below:


for i in {1..100}; do cut -f1 "data_$i.txt" > "output$i.txt"
1,921
Posted By hanson44
If I understand what you are trying to do, try...
If I understand what you are trying to do, try this:
for i in {1..10}; do awk '{$3=i; print}' i=$i data$i.txt > output$i.txt; done
16,087
Posted By Yoda
Please note that variable expansion happens only...
Please note that variable expansion happens only inside double quotes not single quotes.
1,130
Posted By Yoda
awk ' { gsub(/.*\(|\).*/,x) } 1' file
awk ' { gsub(/.*\(|\).*/,x) } 1' file
1,933
Posted By Scott
$ awk '!A[$2]++' file 1 rs4040617 0.08356 ...
$ awk '!A[$2]++' file
1 rs4040617 0.08356
1 rs2977612 0.07948
1 rs2980300 0.08356


This looks much like your previous thread!

And, please start using code tags.
1,452
Posted By Yoda
awk '$1!=$2{$4=$4*2}$1==$2{$4=$4*2+1}1' file
awk '$1!=$2{$4=$4*2}$1==$2{$4=$4*2+1}1' file
1,611
Posted By Yoda
awk 'f==$1&&s!=$2{print c;print}{f=$1;s=$2;c=$0}'...
awk 'f==$1&&s!=$2{print c;print}{f=$1;s=$2;c=$0}' file
7,472
Posted By user8
If I understood correctly, you could try this: ...
If I understood correctly, you could try this:

awk '$2>($6-1000000) || $2<($7+1000000)'

While thinking twice, I came to the conclusion that the above should better read

awk '$2>($6-1000000)...
4,614
Posted By RudiC
I'm not sure any tool will handle lines at least...
I'm not sure any tool will handle lines at least 4 million chars long (one char cols assumed). Where do these loooong lines come from? A database? Can't they be created in a different way from the...
4,614
Posted By Corona688
Does the first column have a fixed width?
Does the first column have a fixed width?
4,614
Posted By Corona688
Some more information on the file would be nice,...
Some more information on the file would be nice, too. Do the columns have a maximum width? Or better yet, a fixed width?
4,614
Posted By bakunin
The correct procedure involves candles, the...
The correct procedure involves candles, the sacrifice of rum, tobacco and a living chicken, then invoking the following ritual chant ....

Seriously: if we are supposed to help you with a problem...
4,614
Posted By Corona688
Transpose into what? Vice versa?
Transpose into what? Vice versa?
4,614
Posted By Corona688
Standard tool, then. Even ordinary awk can...
Standard tool, then.

Even ordinary awk can handle this if you fiddle with the record and field separators so it reads one column at a time, what to do with it is the question. Millions of columns...
3,724
Posted By Vi-Curious
:%s/<space>/<tab>/
:%s/<space>/<tab>/
1,672
Posted By Scrutinizer
Try: awk '{if(NF==1)$0=p FS $0; else p=$1 FS...
Try:
awk '{if(NF==1)$0=p FS $0; else p=$1 FS $2}1' file
1,752
Posted By Scrutinizer
awk '{s=$1; for(i=$2; i<=$NF; i++) s=s OFS i;...
awk '{s=$1; for(i=$2; i<=$NF; i++) s=s OFS i; print s}' file
1,752
Posted By Yoda
awk '{ printf "%d ",$1; j=$2; while(j<=$NF) {...
awk '{ printf "%d ",$1; j=$2; while(j<=$NF) { if(j==$NF) { printf "%d\n",j; j++; } else { printf "%d ",j; j++; } } }' filename
1,730
Posted By Scrutinizer
Try: awk '{$3=0 OFS $3}1' file
Try:
awk '{$3=0 OFS $3}1' file
2,380
Posted By Yoda
sort -k4,4gr input.txt
sort -k4,4gr input.txt
8,388
Posted By elixir_sinari
Assuming that your lines_file contains each line...
Assuming that your lines_file contains each line number on a separate line (and that you don't want to consider duplicate line numbers, if they exist):
awk 'FNR==NR{a[$1];next}FNR in a' lines_file...
1,245
Posted By vgersh99
awk '{$2=$2<=3?"LOW":($2<=6)?"HIGH":"UNKNOWN")}1'...
awk '{$2=$2<=3?"LOW":($2<=6)?"HIGH":"UNKNOWN")}1' file
11,129
Posted By bmk
we can do with elseif.. awk -F'|' '{if($2=="1")...
we can do with elseif..
awk -F'|' '{if($2=="1") {print $1"|"$5} else if($2=="2") { print $1"|"$5"|"$7}}' test.txt
Showing results 1 to 25 of 94

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