Search Results

Search: Posts Made By: jolecanard
14,141
Posted By jolecanard
Thanks! All the solutions proposed work...
Thanks!

All the solutions proposed work fine.
For my use, Alister's is the most convenient (compact and self-contained).
14,141
Posted By jolecanard
awk - loop from a to z
Hello,

I was wondering if it is possible to do a loop on letters rather than numbers with awk (gawk).

Basically I used to do:
echo "nothing" | gawk '{for(i=1;i<11;i++)print i}'

But I would...
12,079
Posted By jolecanard
Thanks for the answer. This works fine, but...
Thanks for the answer. This works fine, but however this is not efficient.

With CSH, I cannot get the time function work even with a simple allocation.

Things that work with CSH:
time...
12,079
Posted By jolecanard
How to "time" a loop in CSH ?
Hi,

I am trying to estimate the time that each part of my program takes to execute. With BASH, I used to use time:
#!/bin/bash
time while [ $go ]
do
....
....
done

This work just fine....
4,755
Posted By jolecanard
Thanks, Those two last solutions work just...
Thanks,

Those two last solutions work just fine!
4,755
Posted By jolecanard
I am trying to define several variables using an...
I am trying to define several variables using an awk script. The awk part will parse "my_file" make some operation, and return a single value.

For each different value of "k", the awk script will...
4,755
Posted By jolecanard
I could not get anything working...
I could not get anything working...
4,755
Posted By jolecanard
To this point I knew it. The problem is that...
To this point I knew it.

The problem is that I want to use it blindly:

k=1
while [ $k -le 10 ]
do
eval zo${k}=`awk -v k=$k {my_script} my_file`
echo $zo${k} -> That does not work
...
4,755
Posted By jolecanard
bash - Variable made of variable
Hello,

I am struggling with using variable made using "eval".

a=4
eval b$a=20

echo $b$a ??? [does not work]

As shown above, I am trying to call back the variable "bX" assuming I do not...
2,821
Posted By jolecanard
bash - define a variable
Hello,

I would like to define a variable based on another variable:
a=5
b$a=100

This does not work. What is the right way to do it?

Thanks

---------- Post updated at 07:37 PM ----------...
12,389
Posted By jolecanard
Perfect! Thanks!!
Perfect! Thanks!!
12,389
Posted By jolecanard
Thanks for your answer!! I will try that...
Thanks for your answer!!

I will try that right now. However, there is one more thing: in reality I want to skip the first argument. I know I can use a "if" condition so that if $i == 1, then I do...
12,389
Posted By jolecanard
Make a list in bash out of arguments
Hello,

I have a very stupid/simple problem, but for some reason I cannot figure out...and I need your help!

I am writting a bash scrip that should be executed using "my_script X Y Z T" where...
3,785
Posted By jolecanard
Thanks, that is what I was looking for!
Thanks, that is what I was looking for!
3,785
Posted By jolecanard
Regular expression in AWK
Hello world,

I was wondering if there is a nicer way to write the following code (in AWK):


awk '
FNR==NR&&$1~/^m[24689]$/{tok1=1}
FNR==NR&&$1~/^m10$/{tok1=1}
' my_file


In fact, it...
13,287
Posted By jolecanard
Unfortunately I cannot. If I do that, I don't...
Unfortunately I cannot. If I do that, I don't read any file with awk, so it won't run.

I know I could use:
echo "blah" | awk -v a=$a -v b=$b '{...}'

but in that case it does not do at all...
13,287
Posted By jolecanard
I already tried it and it does not give the...
I already tried it and it does not give the expected result! :(
13,287
Posted By jolecanard
Multiple pipes toward a single awk command
Hello,

I would like to pipe two variables into awk, but I don't know how to do.

Each variable, "a" and "b", are in fact a list of data. They are not files.
So to get awk to work with it I am...
6,289
Posted By jolecanard
AWK - compare $0 to regular expression + variable
Hi,

I have this script:
awk -v va=45 '$0~va{print}' flo2

That returns: "4526745 1234 " (this is the only line of the file "flo2".

However, I would like to get "va" to match the begining...
1,276
Posted By jolecanard
Finally I found!! Just posting the message helped...
Finally I found!! Just posting the message helped me figuring out the solution:

In the end of the first read file, it found an occurence of ^m2 (m201), and then when it closes the first file and...
1,276
Posted By jolecanard
Error in multiple files treatment with AWK
Hello,

My code is like that:


awk -v f=92238 '$1~/^m2/{tok1=1;next}tok1==1&&$0~f{tok1=0;print $NF}' inp.[1-9] inp.1[0-5]


Eahc of the "inp.*" file is like that:

...
m1 xxxx xxxx
...
2,741
Posted By jolecanard
Awesome!!! :) :b:
Awesome!!! :)

:b:
2,741
Posted By jolecanard
Unfortunately I cannot not assign a variable like...
Unfortunately I cannot not assign a variable like that in my awk script ( ^ syntax error)...
2,741
Posted By jolecanard
AWK: formating number without printf
Hello,

I wrote a script that does lot of things, and I would like to change the format of a number but without printing it now (so I don't want to use printf as it will print the value...
4,439
Posted By jolecanard
Thank you!
Thank you!
Showing results 1 to 25 of 41

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