Search Results

Search: Posts Made By: zajtat
1,080
Posted By MadeInGermany
You certainly want a `subshell` (backticks!) or...
You certainly want a `subshell` (backticks!) or $(subshell)
for i in `ls -d *.gtc.txt|cut -d "." -f1`
do
echo "$i"
done
A bit more elegant is to simply loop over the existing files and use...
1,113
Posted By MadeInGermany
Or awk 'length($5)==1 && length($6)==1' in.file...
Or
awk 'length($5)==1 && length($6)==1' in.file > out.file
945
Posted By Akshay Hegde
You are very close to solution try this awk...
You are very close to solution try this

awk '{printf $1 OFS $2 OFS "0" OFS "0" OFS $9 OFS $10 OFS; for(i=3;i<=8;i++) printf "%s ",$i ; print ""}' infile
1 2 0 0 9 10 3 4 5 6 7 8
1 2 0 0 9 10 3...
945
Posted By sea
Yes i did thought to write it out. So, this...
Yes i did thought to write it out.
So, this would mean, the changes are only to 'insert' two empty (as in contains '0') colums replacing colum 3 to (max colums - 2), and append those columns (3 to 2...
1,047
Posted By SriniShoo
@RudiC code with better performance awk...
@RudiC code with better performance

awk 'BEGIN {for(i=1; i<=1000000; i++) t = (t " 0")} {printf "%s%s\n", $0, t}' file1 > file2
1,047
Posted By RudiC
You didn't mention a header in your spec nor in...
You didn't mention a header in your spec nor in your input file. And in your sample code, you tried to add less than 1000000 fields to make it total 1000000. Run it from i=1 to add 1000000 fields.
1,093
Posted By Scrutinizer
If you use grep -f like that, there are certain...
If you use grep -f like that, there are certain aspects you need to know:

It is inaccurate, since the match should only occur in the second field, but this will match any occurrence on the line,...
718
Posted By Scrutinizer
Try: awk 'NR==FNR{A[$1]=A[$1] OFS $2;...
Try:
awk 'NR==FNR{A[$1]=A[$1] OFS $2; next}{print $1, A[$1]}' file1 file2
853
Posted By bartus11
Try:awk...
Try:awk 'NR==FNR{x=$1;$1="";a[x]=$0;next}{$3=$3""a[$1]}1' file2 file1
6,079
Posted By Scrutinizer
There is a carriage return character with a line...
There is a carriage return character with a line feed in the last sample, so that means it is in DOS-format. You can convert it to Unix Format like so:
tr -d '\r' < file.in > file.out
6,079
Posted By Scrutinizer
Another awk: awk ' NR==FNR{ A[$1] ...
Another awk:
awk '
NR==FNR{
A[$1]
next
}
{
s=$1
for(i=2; i<=NF; i++){
if(FNR==1) for(j in A) if($i~j) D[i]
if( ! (i in D) ) s=s OFS $i
}
print s...
6,079
Posted By Chubler_XL
try awk ' FNR==NR{P[$1];next} FNR==1{ ...
try
awk '
FNR==NR{P[$1];next}
FNR==1{
for(i=1;i<=NF;i++) {
c=$i
sub(/\.[XYZ]$/,"",c)
if(c in P)S[i]
}
}
{ a=x
for(i=1;i<=NF;i++)
if(!(i in S))...
6,079
Posted By rdrtx1
try also: awk ' NR==FNR {p[$0]=$0; next} ...
try also:
awk '
NR==FNR {p[$0]=$0; next}
FNR==1 {for (i=1; i<=NF; i++) {s=$i; sub("[.].*","",s); if (p[s]) o[i]=s}}
{l=""; for (i=1; i<=NF; i++) if (!o[i]) l=l $i" "; $0=l;}
1
'...
748
Posted By jim mcnamara
while read i do command ./$i/$i-ceu-unique >...
while read i
do
command ./$i/$i-ceu-unique > ./$i/$i-ceu-unique-output
command ./$i/$i-yri-unique > ./$i/$i-yri-unique-output
command ./$i/$i-common > ./$i/$i-common-ouput
done < namefile
...
1,076
Posted By tarun_agrawal
try this awk 'NR==1{;a=$0}...
try this


awk 'NR==1{;a=$0} NR>1{for(i=1;i<NF;i++) {v=$(i+1);r=$1;b=$0;$0=a;c=$i;$0=b;print r c":"v }; }' file
Showing results 1 to 15 of 15

 

Featured Tech Videos

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