Search Results

Search: Posts Made By: pamu
3,412
Posted By Jotne
request A123, valueA, valueB B234, valueA,...
request
A123, valueA, valueB
B234, valueA, valueB
C345, valueX, valueY
D456, valueX, valueY
E567, valueA, valueB
F678, valueA, valueB
G789, value A, valueB


Replacing file1 and file2 in...
2,796
Posted By Corona688
Incorrect, they take parameters just fine. ...
Incorrect, they take parameters just fine.

You call them directly, outside [ ], like you would an external program.

if g1 $1 $2 $3
then
...
else
...
fi

And your function should use...
16,358
Posted By balajesuri
Did you try cygwin?
Did you try cygwin?
16,358
Posted By Franklin52
Have you tried the gawk version for windows?
Have you tried the gawk version for windows?
1,943
Posted By Scrutinizer
Hi Kumar, from man printf: So ...
Hi Kumar, from man printf:



So

printf "%0*d" 10 "$b"
works like
printf "%010d" "$b"
3,342
Posted By Don Cragun
Thanks for the compliment, paum. But, after I...
Thanks for the compliment, paum. But, after I looked at it again in red, I see that it is more complex than it needs to be. That red line should be replaced with:
$i = $i != "" ? $i : (i...
3,342
Posted By Don Cragun
Hi pamu, I believe this meets all of Arun's...
Hi pamu,
I believe this meets all of Arun's updated requirements.

Could you explain why you thought you needed the NF>1 and the NF==1 tests in the first invocation of awk?

I'm not a big fan of...
2,169
Posted By Scrutinizer
See if this works: perl -pe...
See if this works:
perl -pe 's/(^|(?<=\|))([0-9.]+)\.(\||$)/$2$3/g' file
1,670
Posted By Scrutinizer
Alternatively: awk -F, '{A[$1]; B[$2];...
Alternatively:
awk -F, '{A[$1]; B[$2]; C[$1,$2]++} END{for(i in A){p=i; for(j in B)p=p FS j "=" C[i,j]+0; print p}}' file
1,447
Posted By elixir_sinari
With awk: awk 'FNR==NR{a[$0];next}{p=1;for(i in...
With awk:
awk 'FNR==NR{a[$0];next}{p=1;for(i in a) if($0~i) {p=0;break}}p' data2delete file2
7,770
Posted By Neo
Hey figaro, As I have replied; if you have...
Hey figaro,

As I have replied; if you have an icon you want to see, please create it or find it on the net and post it as an attachment. It must be 32 x 32 pixels.

In other words, if you...
1,509
Posted By Scrutinizer
awk version: awk 'NR==FNR{A[$1]; next}...
awk version:
awk 'NR==FNR{A[$1]; next} FILENAME!=ARGV[1] && $1 in A{print $0,FILENAME}' file * | sort -k1,1 -k4,4



--
@pamu: probably need to fix $x to avoid incomplete matches, for example:...
Forum: What is on Your Mind? 10-18-2012
1,502
Posted By Neo
Hi amora, Thank you for those kinds words. ...
Hi amora,

Thank you for those kinds words. You make me and all the other team members feel good about the work we all put into these forums.

I know it sounds a bit overstated; but often when I...
2,589
Posted By Scrutinizer
One awk: awk ' f==2{ F2[$2]=$8 ...
One awk:

awk '
f==2{
F2[$2]=$8
}
f==3{
F3a[$2]=$9
F3b[$2]=$10
}
f==1{
$8=F2[$2]
$9=F3a[$2]
$10=F3b[$2]
print
}
' f=2 file2 f=3 file3 f=1 file1
2,747
Posted By elixir_sinari
Why do you simplify your problems? Just state...
Why do you simplify your problems? Just state them as they are.
awk '{a[NR]=$0}
END{h=(NR%2)?int(NR/2+1):(NR/2)
j=h+1
for(i=1;i<=h;i++)
print a[i],a[j++]
}' OFS=: tmp.txt
6,737
Posted By elixir_sinari
There is a big difference between how you handle...
There is a big difference between how you handle files and variables. You mention variables in one post (and in the thread title) and files in the other.

Please don't try to oversimplify the...
2,785
Posted By asavaliya
Just Amazing ...............just...
Just Amazing ...............just awesome................

Thanks a lot ....You r genius :):):):):):):):)
4,722
Posted By jim mcnamara
in bash try: type [ type [[ They...
in bash try:

type [
type [[


They are both part of the shell: [ is a keyword like if, while, etc.: [[ is a shell builtin but still is treated a a word.

"word" is key here, because words...
4,722
Posted By elixir_sinari
What is that, pamu? Variable expansion will be...
What is that, pamu?
Variable expansion will be done by the shell in any case (in case of double-quotes). The double-quotes are to retain the embedded spaces and/or to tell the shell that the...
2,044
Posted By Don Cragun
Try the following: awk -F "(<[/]*tag|>)" ' { ...
Try the following:
awk -F "(<[/]*tag|>)" '
{ for(i = 2; i <= NF; i += 4) {
o[NR,$i] = $(i + 1)
if($i > maxf) maxf = $i
}
}
END { for(i = 1; i <=...
1,386
Posted By elixir_sinari
awk -F,...
awk -F, 'BEGIN{split("Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec",mname,",")
for(i=1;i<=12;i++) mnum[mname[i]]=i}
{mon=mnum[substr($3,1,3)];yr=substr($3,4,2);
$0=$0"/"$4;for(i=1;i<=$4;i++){
...
1,961
Posted By Corona688
Yes, this is how if is meant to be used. It...
Yes, this is how if is meant to be used. It checks the return status of the command given.

If in doubt, remember, [ is a command.

$ whereis '['

[: /usr/bin/[

$ Usually a shell builtin,...
4,640
Posted By elixir_sinari
Now, what does that mean (NR being always same)?...
Now, what does that mean (NR being always same)? That might not work only because ! has a higher precedence than %. So the expression !NR%60 is evaluated as follows:
1) Negate the value of NR. This...
5,089
Posted By A-V
FILES01="F1/*" for T in $FILES01 do ...
FILES01="F1/*"
for T in $FILES01
do
name=$(basename $T)
for X in james mark john peter sam
do
for Y in james mark john peter sam
do
for Z in james mark john peter sam
do

if [[ `grep...
11,281
Posted By elixir_sinari
Turn on extglob (shopt -s extglob).
Turn on extglob (shopt -s extglob).
Showing results 1 to 25 of 55

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