Search Results

Search: Posts Made By: f_o_555
3,353
Posted By RudiC
That's easier with sed unless you process the...
That's easier with sed unless you process the file with awk anyhow beforehand in which case you should include the append there. Try
sed '$!s/$/ \&/' file
4.465E+17 &
5.423E+16 &
1.218E+17 &...
3,353
Posted By RavinderSingh13
Hello f_o_555, Could you please try...
Hello f_o_555,

Could you please try following and let me know if this helps you.

awk 'FNR==NR{count++;next} FNR<count{print $0 FS "&";next} 1' Input_file Input_file
Thanks,
R. Singh
1,693
Posted By RavinderSingh13
Hello f_o_555, Could you please try...
Hello f_o_555,

Could you please try following and let me know if this helps you.

awk 'BEGIN{print "TEXT A"} {print $1 FS "A"} END{print $2}' Input_file
Thanks,
R. Singh
1,531
Posted By RudiC
Assuming that your awk doesn't forget $1 nor NF...
Assuming that your awk doesn't forget $1 nor NF in the END section, try:awk '{for (i=2; i<=NF; i++) SUM[i]+=$i} END {printf "%s", $1; for (i=2; i<=NF; i++) printf "%s%s", FS, SUM[i]; printf "\n"}'...
1,401
Posted By RudiC
NewName has the value " 12". Print it within...
NewName has the value " 12". Print it within double quotes:N=$(printf "%*s" 3 $1)
echo $N
12
echo "$N"
12
Please note there's a double quote missing in your assignment...
1,143
Posted By disedorgue
Hi, in bash: $ ROW=3 && COL=15 && sed -e...
Hi, in bash:
$ ROW=3 && COL=15 && sed -e "$((ROW+1))s/./X/${COL}" file
#-----------------------------------
3 ! number of parameters of the polynome
0.00000e+00 0 ! fix=0)...
1,143
Posted By anbu23
$ sed "/.\{14\}1/s/./0/15" file ...
$ sed "/.\{14\}1/s/./0/15" file
#-----------------------------------
3 ! number of parameters of the polynome
0.00000e+00 0 ! fix=0) free=1
1.03916e-03 0 ! fix=0) free=1...
1,736
Posted By RavinderSingh13
Hello f_o_555, I am not sure how you have...
Hello f_o_555,

I am not sure how you have tried running command with other files, but please make sure about command like first file should have 3 fields and 2nd passed file should have 2 fields...
1,736
Posted By RavinderSingh13
Hello f_o_555, Could you please try...
Hello f_o_555,

Could you please try following and let me know if this helps.

awk 'FNR==NR{X[$1]=$0;next} ($1 in X){print X[$1]} !($1 in X){print $1 OFS "NOT" OFS "FOUND."}' OFS="\t" file2...
2,102
Posted By RudiC
Try alsoawk '{getline X < F1; print $1, X*$2}'...
Try alsoawk '{getline X < F1; print $1, X*$2}' F1=file2 file1 | sort -nr -k2
CCCCC 5.45692e-34
BBBBB 5.09198e-15
AAAAA 1.36289e-23
DDDDD 0
2,102
Posted By bharat1211
file 1: ...
file 1:
AAAAA 3.465830E-12
BBBBB 4.263280E-08
CCCCC 1.113320E-17
DDDDD 0.000000E+00

file 2:

3.932350E-12
1.194380E-07
4.901480E-17...
3,579
Posted By MadeInGermany
A bit shorter awk '{out = 0; for(i = 3; i <=...
A bit shorter
awk '{out = 0; for(i = 3; i <= NF; i+=2) {out += $(i-1) * $i }; print out}' file
3,579
Posted By SriniShoo
If you are so sure about what you said, below is...
If you are so sure about what you said, below is the code
awk '{out = 0; for(i = 2; i <= NF; i++) {if(i % 2 == 0) {p = $i} else {out = out + (p * $i)}}; print out}' file
2,386
Posted By guruprasadpr
Hi Either this if test -f...
Hi

Either this
if test -f "$file_name"
or this:
if [ -f "$file_name" ]
2,386
Posted By jayan_jay
if [ -f "$file_name" ]; then echo File...
if [ -f "$file_name" ]; then
echo File $file_name Found
else
echo File $file_name Not Found
fi


Alternate one ..

$ [ -f "$file_name" ] && echo "Filename $file_name Found"...
1,740
Posted By Corona688
if awk -v A="1.23e+01" -v B="3.21e+02" 'BEGIN {...
if awk -v A="1.23e+01" -v B="3.21e+02" 'BEGIN { if(A>B) exit 0; exit 1 }'
then
echo "A>B"
else
echo "A<=B"
fi
2,220
Posted By itkamaraj
awk '{print $2}' file1 > file3 fgrep -f file3...
awk '{print $2}' file1 > file3
fgrep -f file3 file2
2,220
Posted By birei
Hi f_o_555, I don't understand your v>6e-31...
Hi f_o_555,

I don't understand your v>6e-31 condition in the 'awk' command. Try if next one works for you:

$ cat file1
BB152 6.279650E+02
AA124 6.279650E+02
$ cat file2
AA124 ...
4,731
Posted By shamrock
join -a 2 -e " " -o 1.1 1.2 2.1 2.2 file1...
join -a 2 -e " " -o 1.1 1.2 2.1 2.2 file1 file2
2,033
Posted By ahamed101
sort the output if that helps i.e. awk '{...}'...
sort the output if that helps i.e. awk '{...}' input_file | sort
or
Try this...

awk '{sum+=$3;a[++j]=$0}END{for(i=1;i<=j;i++){split(a[i],arr);if(arr[3]/sum > val){print a[i]}}}' val="0.016"...
2,033
Posted By ahamed101
Try this... awk '{sum+=$3;a[$0]=$3}END{for(i...
Try this...

awk '{sum+=$3;a[$0]=$3}END{for(i in a){if(a[i]/sum > val){print i}}}' val="0.016" input_file


--ahamed
2,033
Posted By balajesuri
#! /usr/bin/perl -w use strict; my ($line,...
#! /usr/bin/perl -w
use strict;

my ($line, $sum, $crtn_value, $ratio) = (0, 0, 1e-4, 0);
my (@x);

open INPUT, "< input.txt";
for $line (<INPUT>) {
@x = split /\s+/, $line;
$sum =...
1,380
Posted By ahamed101
Try this... awk 'NR==FNR{a[$1]=$2;next} $1...
Try this...

awk 'NR==FNR{a[$1]=$2;next} $1 in a{v=$3*a[$1]}v>6e-31{printf("%s %.5f %s\n",$1,$2,v)}' file2 file1 > file3

The product i.e. $3*a[$1] is too small, so .5f will not print anything...
1,380
Posted By ahamed101
Try this... awk 'NR==FNR{a[$1]=$2;next} $1...
Try this...

awk 'NR==FNR{a[$1]=$2;next} $1 in a{v=$3*a[$1]}v{print $1,$2,v}' file2 file1 > file3


--ahamed
1,652
Posted By jayan_jay
split -3506 infile paste -d' ' xa* > outfile ...
split -3506 infile
paste -d' ' xa* > outfile
rm xa*
Showing results 1 to 25 of 44

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