Search Results

Search: Posts Made By: guns
4,205
Posted By tarun_agrawal
echo "1 2 3 4 5 6 7 9 12" | awk -v var=2...
echo "1 2 3 4 5 6 7 9 12" | awk -v var=2 '{for(i=3;i<=NF;i=i+3) {$i= $i*var} }1'
4,832
Posted By itkamaraj
try this.. nawk...
try this..


nawk '{for(i=0;i<=NF;i++){if(i!=0 && i%3!=0){printf("%s ",$i)}if(i==NF){printf("\n")}}}' inputfile
4,832
Posted By Franklin52
Should be: nawk...
Should be:
nawk '{for(i=1;i<=NF;i++){if(i%3!=0){printf("%s ",$i)}if(i==NF){printf("\n")}}}' inputfile
1,847
Posted By Scrutinizer
Try: while read dir; do echo "$dir" ...
Try:

while read dir; do
echo "$dir"
done < directory.txt
1,372
Posted By binlib
paste A.txt B.txt C.txt |awk '{print ($1+$3)/$5,...
paste A.txt B.txt C.txt |awk '{print ($1+$3)/$5, ($2+$4)/$6}'
1,372
Posted By vgersh99
nawk -f guns.awk A.txt B.txt C.txt guns.awk: ...
nawk -f guns.awk A.txt B.txt C.txt
guns.awk:

FNR==1{f++}
{
for(i=1;i<=NF;i++)
file[f,FNR,i]=$i
fnr=FNR
nf=NF
}
END{
for(i=1;i<=fnr;i++)
for(j=1;j<=nf;j++)
...
1,755
Posted By ahamed101
A small change... Try this... awk...
A small change... Try this...
awk 'NR==FNR{_1[$0]++;next}{for(i in _1){for(j=1;j<=i+0;j++){printf $0 FS}printf "\n"}}'
File2.txt File1.txt > File3.txt
--ahamed
4,535
Posted By rdcwayx
This will lost original sequence, you can't short...
This will lost original sequence, you can't short it by this way.

That's why I use below code.
for (i=1;i in a;i++)
20,543
Posted By rdcwayx
You should use FNR (not NR) to control multiple...
You should use FNR (not NR) to control multiple files.

awk '{a[FNR]=a[FNR] FS $2;t=(FNR>T)?FNR:t}END {for (i=1;i<=t;i++) print a[i]}' file1 file2 file3 file4
Showing results 1 to 9 of 9

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