Search Results

Search: Posts Made By: ida1215
1,030
Posted By SriniShoo
awk -v fname='japan usa uk' 'BEGIN {split(fname,...
awk -v fname='japan usa uk' 'BEGIN {split(fname, a)}
{for(i = 1; i <= NF; i++)
{print $i > ("201005" a[i] ".txt")}}' alldata.dat
1,314
Posted By Don Cragun
awk ' NR == FNR {a[FNR] = $0; n = FNR; next} ...
awk '
NR == FNR {a[FNR] = $0; n = FNR; next}
{ f = sprintf("output%02d.txt", ++c)
for(i = 1; i <= n; i++)
print a[i], $0 > f
close(f)
}' file1.txt file2.txt
1,314
Posted By Don Cragun
This will work fine on many systems as long as...
This will work fine on many systems as long as there aren't too many lines in file2.txt. On other systems, you'll get a syntax error on the print statement. If there are a lot of lines in...
1,314
Posted By SriniShoo
awk 'NR == FNR {a[FNR] = $0; n = FNR; next} ...
awk 'NR == FNR {a[FNR] = $0; n = FNR; next}
{c++;
for(i = 1; i <= n; i++)
{print a[i], $0 > "output" c ".txt"}}' file1.txt file2.txt
1,451
Posted By vbe
the condition is true if the specified file in...
the condition is true if the specified file in variable exist...
1,451
Posted By neutronscott
We loop across the *.asc files, and figure out...
We loop across the *.asc files, and figure out what the csv would be by stripping everything after the "_" and tacking .csv to the end... right?

Try this:


for asc in *.asc; do
...
4,018
Posted By Don Cragun
That line creates an array (f1[]) of the values...
That line creates an array (f1[]) of the values found in the 1st column ($1) of the 1st input file (when FNR {the line number in the of the input lines read from the current file} is equal to NR {the...
4,018
Posted By Don Cragun
The for i in {1..3} works in some shells, but not...
The for i in {1..3} works in some shells, but not others. Since the first line of your script doesn't specify what shell you want, it will run using your system's default shell. Then $i in your awk...
4,444
Posted By elixir_sinari
If you are using print, use OFMT='%.2f'. awk -f...
If you are using print, use OFMT='%.2f'.
awk -f interp.awk STEP=0.2 OFS="\t" OFMT='%.2f' data
Or, you may use printf.
3,660
Posted By Scrutinizer
Hi, it means "if the first field does not contain...
Hi, it means "if the first field does not contain a letter" . [:alpha:] is a character class (http://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap07.html#tag_07_03_01).
3,660
Posted By Scrutinizer
Try: awk ' NR==FNR{ A[$1]=$2 ...
Try:

awk '
NR==FNR{
A[$1]=$2
if( $1!~/[[:alpha:]]/ ) {
if( min=="") min=max=$1
if( $1<min ) min=$1
if( $1>max ) max=$1
}
next
}
{
v=$1
...
4,444
Posted By Corona688
$ cat interp.awk (STEP=="") { STEP=1 } U { ...
$ cat interp.awk

(STEP=="") { STEP=1 } U {
D=(U<$1)?1:-1;
M=((V-$2)/(U-$1)) * D * STEP;

while( ((-D)*((U+=(D*STEP)) - $1)) > (STEP/2))
print U, V +=...
1,784
Posted By Corona688
Your data doesn't seem to have a normal...
Your data doesn't seem to have a normal distribution.

There's a much more obvious way anyway, don't know why it didn't occur to me before :confused: Sort it, then look past the % number of lines...
5,845
Posted By Corona688
= is assignment, == is comparison. This is true...
= is assignment, == is comparison. This is true in both perl and awk.

awk 'NR==1 { print }' would print the first line and only the first line.
5,845
Posted By balajesuri
Ha, ha! Another classic example of changing...
Ha, ha! Another classic example of changing requirements. Ok, here's some light:

if($. == 1) {print; next} ==> This part of the code checks if line in consideration is line #1 and if so prints the...
1,735
Posted By msabhi
Try this...i don't think with xargs its...
Try this...i don't think with xargs its achievable...

1>Write all the file names into a text file
ls *txt > temp
2>Execute this command to see what you really desired to see
perl -lne...
1,735
Posted By msabhi
ls *txt | xargs -n6 paste
ls *txt | xargs -n6 paste
10,249
Posted By itkamaraj
awk '$1<0{$0=0}1' input.txt perl -lane...
awk '$1<0{$0=0}1' input.txt
perl -lane 'if($_<0){print "0"}else{print $_}' input.txt
10,249
Posted By Scrutinizer
awk -F- '{$0=$1+0}1' infile
awk -F- '{$0=$1+0}1' infile
10,249
Posted By elixir_sinari
awk '$0+0<0{$0=0}1' inputfile or sed...
awk '$0+0<0{$0=0}1' inputfile

or

sed 's/^-.*/0/' inputfile
4,774
Posted By Corona688
paste can handle lots of files. You'll have to...
paste can handle lots of files. You'll have to be more specific, I don't see any good reason it wouldn't work for you yet.
4,774
Posted By bartus11
So you mean you have more than three files...
So you mean you have more than three files containing your data?
10,702
Posted By Corona688
Are you sure your output there is right? I get...
Are you sure your output there is right? I get your numbers for the first, but your second appears to have an extra zero in the middle.

awk '{ A=0; V=0; for(N=1; N<=NF; N++) A+=$N ; A/=NF ;...
2,031
Posted By clx
Another way.. awk '$0=($0<0)?$0+360:$0'...
Another way..

awk '$0=($0<0)?$0+360:$0' file
2,031
Posted By hergp
awk '{ if ($1 < 0) $1 = $1 + 360; print; }'...
awk '{ if ($1 < 0) $1 = $1 + 360; print; }' inputfile >outputfile
Showing results 1 to 25 of 63

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