Search Results

Search: Posts Made By: paresh n doshi
2,369
Posted By paresh n doshi
To select non-duplicate records using awk
Friends,

I have data sorted on id like this

id addressl
1 abc
2 abc
2 abc
2 abc
3 aabc
4 abc
4 abc

I want to pick all ids with addressesses leaving out duplicate records. Desired...
1,790
Posted By paresh n doshi
try this grep -F $A *.txt
try this

grep -F $A *.txt
2,214
Posted By paresh n doshi
try this: awk -F"mdn"...
try this:
awk -F"mdn" "{a[NR]=$0}/WARNING/{$0=a[NR-4];print substr($2,2,9)}" file | sort | uniq
1,663
Posted By paresh n doshi
printf "%s\n%s\n" 10,250.00 20,103.15 | awk...
printf "%s\n%s\n" 10,250.00 20,103.15 | awk '{var=$1;gsub(/,/,x,var);print var}'
printf "%s\n%s\n" 10,250.00 20,103.15 | awk '{gsub(/,/,x,$1);print $1}'
both gave same result, sir.
Thank you
1,663
Posted By paresh n doshi
Thanks. One more query. Is it possible to...
Thanks. One more query. Is it possible to assign the result of gsub to a variable?
like
var=gsub(/,/,"",$1)
1,663
Posted By paresh n doshi
Add edited numeric strings in awk
I am using awk to sum up all amounts and at end print total.

input:
10,250.00
20,103.15


expected output:
30353.15

code:
{subtot=+$1} END{print subtot}

The problem I encounter is it...
4,732
Posted By paresh n doshi
sir, code awk '/Output view:/{f=1; $0=$0...
sir,

code
awk '/Output view:/{f=1; $0=$0 p; p=x} !f{p=p RS $0} f' file

works fine. But can you explain me step by step by step how it works.
3,486
Posted By paresh n doshi
CAN YOU PLEASE EXPLAIN WHAT {A[$1]++" EXACTLY "...
CAN YOU PLEASE EXPLAIN WHAT {A[$1]++" EXACTLY " DOES? IT IS CREATING AN ARRAY BUT NOT ASSIGNING ANYTHING. FURTHER INCREMENT SIGN IS NOT UNDERSTOOD BY ME. PLEASE HELP ME UNDERSTAND THIS.

No...
3,259
Posted By paresh n doshi
grep "human" infile | awk ' { for (i=1;i<=NF;i++)...
grep "human" infile | awk ' { for (i=1;i<=NF;i++)
if(($i) ~ /name=/) count[$i]++}
END { print "human = "NR;
for (a in count)
{ t=length(a)-6; print substr(a,6,t),"=",count[a]}}'
1,181
Posted By paresh n doshi
try this cat infile | awk "...
try this

cat infile | awk " {rec[$1]=$1;c[$1]++} END { for (a in rec) print rec[a],c[a]} "
1,326
Posted By paresh n doshi
try this awk ( stored in a file) ...
try this awk ( stored in a file)

{rec=$0;endthis=1;this=1;len=length(rec)/2}
END { while (endthis<len+1)
printf("%s\n",substr(rec,this,100));
this+=100;endithis++;}}
2,705
Posted By paresh n doshi
echo a,b,c,d,e,f,g,h,i | awk 'NR>5 && $1~/f/...
echo a,b,c,d,e,f,g,h,i | awk 'NR>5 && $1~/f/ {print "yes"}' RS=,

I guest $5~/f/ { print $0 } would print the record if the fifth column has f in it.
1,047
Posted By paresh n doshi
Than you. This worked. But one thing I wanted to...
Than you. This worked. But one thing I wanted to know,
my code looks fine, but returns nothing. If someone can help me
understand how array is handled here, it will help me with other such...
1,047
Posted By paresh n doshi
Pick a line in file 2 basing on array in file1
Dear friends,

I have two files. One with all IDs(in a single field) . And another with data(of which say field 5 is ID). I want to create an array of IDs using first file and
while reading...
671
Posted By paresh n doshi
Thank you very much. The problem was elsewhere...
Thank you very much. The problem was elsewhere and my focus in some other place.
This changed set my problem right. Thanks a lot
671
Posted By paresh n doshi
Since there are four record to match with array,...
Since there are four record to match with array, the result I expect is four or less. But the awk returns 8 records, and I did not follow how. I had in mind the following result

20
30
...
671
Posted By paresh n doshi
About arrays in file 1 matching with file 2
i have two files say a and b
a has these lines

1 20 30 40
2 30 40 50
3 25 35 45
5 20 50 20


and b has these lines


20 30
30 40
25 35
20 50

the script reads
FILENAME ( "a" )...
2,424
Posted By paresh n doshi
If you want the line to be printed where second...
If you want the line to be printed where second column begins with 33
try this
awk ' { if (substr($2,1,2)==33) print $0 } ' filename

if you want to print only that column say print $2

A...
1,856
Posted By paresh n doshi
some homework and got the solution. my...
some homework and got the solution.

my default shell interpreter is bsh/sh
adding a line at the beginning was the trick
SHELL=/bin/ksh


thank u anyway
1,856
Posted By paresh n doshi
#my script is file named "q" and input comes from...
#my script is file named "q" and input comes from file named "file1"
paste <(cut -c37-42 file1) <(cut -c43-53 file1 |amtawk )
q: syntax error at line 1: `(' unexpected
"paste <(cut -c37-42...
1,856
Posted By paresh n doshi
list in shell
when i give this command at prompt it works
paste <(cut -f1 file1) <(cut -f3 file2) | someawkscript
but when the same is addex to any shell script and run it does not work
the erro is at (
even...
8,363
Posted By paresh n doshi
a=2 b=9 c='echo $a+$b | bc' echo $c ...
a=2
b=9
c='echo $a+$b | bc'
echo $c


this should work
8,363
Posted By paresh n doshi
a=2 b=3 c='echo $a+$b | bc' echo $c ...
a=2
b=3
c='echo $a+$b | bc'
echo $c


# two variables with operator + in between are echoed as a string
and passed on to bc to evaluate, which is stored in variable c.
2,013
Posted By paresh n doshi
shell and vImproved for win env
i have pleasure in using shell scripts and vi editor.
VI Improved on Linux is also good.
Is there a way that allows using shell as command interpretor
and VIm as editor to work on windows? (not...
8,363
Posted By paresh n doshi
use expr instead if u have variables a and b ...
use expr instead
if u have variables a and b
c=` expr $a+$b `
Showing results 1 to 25 of 55

 

Featured Tech Videos

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