10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi,
I'm trying to write an awk function that returns all possible permutations of n items chosen in a list of m items. For example, given the input "a,b,c,d,e" and 3, the function should return the following :
a a a
a a b
a a c
a b a
a b b
...
c a a
c a b
...
e e c
e e d
e e e
(125... (21 Replies)
Discussion started by: cjnwl
21 Replies
2. Shell Programming and Scripting
hello,
I'm reading this thread, in which there is this code :awk '
function comb(v,i) {
for(i in A) {
delete A;
if(length(A))
comb((v?v"+":x)i)
else print v"+"i
A;
}
}
{ A }
END {
comb();
} ' infilebut I can't understand where does v come... (5 Replies)
Discussion started by: daPeach
5 Replies
3. Shell Programming and Scripting
Post #2 is the original post. This is the first answer to post #2
Hi, try:
awk '
{
match($0,/1+/)
b=substr($0,1,RSTART-1)
e=substr($0,RSTART+RLENGTH,length)
for(i=2^RLENGTH-2; i>0; i--) {
s=x; d=i
while(d) {
s=(d%2==0?0:1) s
... (12 Replies)
Discussion started by: Scrutinizer
12 Replies
4. Shell Programming and Scripting
Hello I have a very simple input file in which there are a list of numbers:
1
2
3
4
5
6
7
8
9
10
My actual dataset is about 200 lines long. I was wondering how to add different permutations of 3 numbers for all the numbers in the dataset. For example:
1+2+3; 3+5+7; 2+8+1; 9+3+4... (1 Reply)
Discussion started by: Rabu
1 Replies
5. UNIX for Dummies Questions & Answers
Hi !
Before trying to write a code, is there any program or code that generates all the combinations of strings that simple awk regex can match.
By "simple regex" I mean let's say without "+", "*", and with a limited number of characters (e.g. from "1" to "5").
e.g:
input:
34?5
output:... (9 Replies)
Discussion started by: beca123456
9 Replies
6. Shell Programming and Scripting
Hi,
I have an input file like this
a
b
c
d
I want to print all possible combinations between these records in the following way
aVSb
aVSc
aVSd
bVSc
bVSd
cVSd
VS indicates versus. All thoughts are appreciated. (5 Replies)
Discussion started by: jacobs.smith
5 Replies
7. Linux
Hi Team
when i do, echo on my host box it returns (see below)
# echo $PS1
\$
I need to set a color comination of my own
for \u means for user : red
for \h means for hostname: blue
for \W means present working directory: pink
for $ means for wht prompt : yellow
Do i need to... (1 Reply)
Discussion started by: whizkidash
1 Replies
8. Programming
HI I have a series(sorted), which i require to create combinations. I am not getting the good code for doing this. My series should generate the following combinations... Please help me in getting this in C++. Thanks for your help.
A:
A
A B:
A
B
A B
A B C:
A
... (1 Reply)
Discussion started by: rameshmelam
1 Replies
9. Shell Programming and Scripting
Hi,
I need to generate all combinations upto n-1 level,
if the input file looks like say,
A
B
C
D
.
.
....
I need to generate all combinations such that first value remains constant and the remaning are combined with all possible ways.
Output
A
AB
AC
AD
ABC (1 Reply)
Discussion started by: zorg4u
1 Replies
10. UNIX for Advanced & Expert Users
Hello All,
i have two files, one of the format
A 123
B 124
C 234
D 345
And the other
A 678
B 789
C 689
D 567
I would like to combine them into one file with three columns:
A 123 678
B 124 789
C 234 689 (4 Replies)
Discussion started by: Khoomfire
4 Replies