Sponsored Content
Top Forums Shell Programming and Scripting Script to output custom characters in different order Post 302593880 by drl on Sunday 29th of January 2012 07:56:14 PM
Old 01-29-2012
Hi.

Here's a perl script that uses a module for the hard parts:
Code:
#!/usr/bin/env perl

# @(#) p2	Demonstrate combinations and permutations.

use Math::Combinatorics;

my @n = qw(a b c);
print "combinations of 2 from: " . join( " ", @n ) . "\n";
print "------------------------" . ( "--" x scalar(@n) ) . "\n";
print join( "\n", map { join " ", @$_ } combine( 2, @n ) ), "\n";
print "\n";
print "permutations of 3 from: " . join( " ", @n ) . "\n";
print "------------------------" . ( "--" x scalar(@n) ) . "\n";
print join( "\n", map { join " ", @$_ } permute(@n) ), "\n";

exit(0);

producing:
Code:
% ./p2
combinations of 2 from: a b c
------------------------------
c a
c b
a b

permutations of 3 from: a b c
------------------------------
a b c
a c b
b a c
b c a
c a b
c b a

See perldoc Math::Combinatorics for details ... cheers, drl
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

replacing characters in order to sort

hi, i want to rename all the file names in order so that they can be sorted later. For example, my filenames are like path\1, path\2...path\10, path\11. But when I sort them, it sorts by the first number, so path\1 gets sorted with path\10. I'm guessing the best way to do this is to rename... (5 Replies)
Discussion started by: gammaman
5 Replies

2. Shell Programming and Scripting

output string in reversing order

If I have string { I_love_shell_scripts} anyone knows how to have output {stpircs_llehs_evol_I} by using shell and perl ?I know in perl, there is reverse() funcation, but can it be done by not using reverse()? (3 Replies)
Discussion started by: ccp
3 Replies

3. Shell Programming and Scripting

help removing characters for output file in shell script

hi i'm new to shell scripts and have a small problem i am running a batch converter that returns all flash .flv files in a directory and create a png image from each one the problem i have is the $1 variable , its ok on the first call but on the secound call $1.png , i have extra... (1 Reply)
Discussion started by: wingchun22
1 Replies

4. HP-UX

Output of Custom package scripts to terminal

Hi, I am doing some testing with creation of depots on HP-UX systems (11.11). Want to display some echo statements based on the processing during checkinstall, pre & postinstall scripts on the terminal. The echo statements are getting directed to /var/adm/sw/swagent.log I want to display... (7 Replies)
Discussion started by: vibhor_agarwali
7 Replies

5. Red Hat

Custom output on FIND

I have a file, ENV.doc somewhere in my home directory. I want to know where the file is located in my sub directories using FIND. But, I want to display only the relative path along with the file name. Thanks, (6 Replies)
Discussion started by: ashok.g
6 Replies

6. Shell Programming and Scripting

egrep output order

The order of egrep output seems to be as they occur in the file. How do I get the order as requested? For e.g. file contents: AAA EEE GGG egrep 'GGG|AAA|EEE' file gives AAA EEE GGG instead of GGG AAA EEE (2 Replies)
Discussion started by: madhavb
2 Replies

7. Shell Programming and Scripting

How to print the output in correct order?

Hi, while using following awk commend I’m getting confused, The output is not like as the row present in input files, can anyone explain and tell me how to print in the order like in input. value=$(awk 'FNR>1 && NR==FNR{a=$4;next} a{sum+=$4} END {for(i in sum){printf i"\t"sum/2"@@";}}'... (5 Replies)
Discussion started by: Shenbaga.d
5 Replies

8. Shell Programming and Scripting

awk - Why does output order change?

I have this END section in an awk script: END { for (j in littlebin) { print (j, int(log(j)/log(2)) , littlebin) lbsum+=littlebin } for (i in bins) ... (6 Replies)
Discussion started by: treesloth
6 Replies

9. Shell Programming and Scripting

Custom wget output

The below hides the messy commands of wget #!/bin/bash cd 'C:\Users\cmccabe\Desktop\wget' wget -O getCSV.txt http://172.24.188.113/data/getCSV.csv progressfilt () { local flag=false c count cr=$'\r' nl=$'\n' while IFS='' read -d '' -rn 1 c do if $flag ... (5 Replies)
Discussion started by: cmccabe
5 Replies

10. Shell Programming and Scripting

Awking custom output

i have data that can look like this: echo "Master_Item_Service_is_down=0_njava_lang_NoClassDefFoundError=0_njava_lang_OutOfMemoryError=1_nemxCommonAppInitialization__Error_while_initializing=0_nINFO__Stopping_Coyote_HTTP_1_1_on_http_8080=7_nThe_file_or_directory_is_corrupted_and_unreadable=0_n" ... (7 Replies)
Discussion started by: SkySmart
7 Replies
FENCE_TOOL(8)							      cluster							     FENCE_TOOL(8)

NAME
fence_tool - a utility for the fenced daemon SYNOPSIS
fence_tool [COMMAND] [OPTIONS] DESCRIPTION
This utility controls and queries the fenced(8) daemon with the following commands: join join the fence domain. leave leave the fence domain. dump print the fenced internal debug buffer ont stdout. ls display internal fenced state. The leave command will not be sent to fenced if fence_tool detects that any instances of gfs or dlm are in use. OPTIONS
-n Show all node information in ls. -t seconds Retry cman connection for this many seconds. 0 none, -1 indefinite. Default 0. -q seconds Delay join up to this many seconds for the cluster to have quorum. 0 none, -1 indefinite. Default 0. -m seconds Delay join up to this many seconds for all nodes in cluster.conf to be cluster members. 0 none, -1 indefinite. Default 0. -w seconds Wait up to this many seconds for the result of join or leave. 0 none, -1 indefinite. Default 0. -h Print a help message describing available options, then exit. -V Print program version information, then exit. SEE ALSO
fenced(8) cluster 2009-12-21 FENCE_TOOL(8)
All times are GMT -4. The time now is 10:40 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy