Skip to main content
added 290 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

Mimicking crunch

Something like this will generate all the permutations of the set {a,b} @ 3 strings long, and it will shuffle up the output using shuf.

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa

This is really no different though than using sort -R.

Hiding the randomizing

If you're intending to hide the interface so that you give scriptX a list of arguments and it returns back a randomized list similar to crunch, then wrapping this in an alias or a shell script would do the job. You could put the following into a shell script called mycrunch.bash:

#!/bin/bash

crunch "$1" "$2" "$3" | sort -R

Mark it as executable:

$ chmod +x mycrunch.bash

And run it like so:

$ ./mycrunch.bash 3 3 ab

Filtering bogus crunch output

You can use a grep command within the script above to filter those lines out like so:

crunch "$1" "$2" "$3" | grep -vE "Crunch|0" | sort -R

That will take care of omitting any lines that contain the strings "Crunch" or "0".

Something like this will generate all the permutations of the set {a,b} @ 3 strings long, and it will shuffle up the output using shuf.

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa

This is really no different though than using sort -R. If you're intending to hide the interface so that you give scriptX a list of arguments and it returns back a randomized list similar to crunch, then wrapping this in an alias or a shell script would do the job. You could put the following into a shell script called mycrunch.bash:

#!/bin/bash

crunch "$1" "$2" "$3" | sort -R

Mark it as executable:

$ chmod +x mycrunch.bash

And run it like so:

$ ./mycrunch.bash 3 3 ab

Mimicking crunch

Something like this will generate all the permutations of the set {a,b} @ 3 strings long, and it will shuffle up the output using shuf.

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa

This is really no different though than using sort -R.

Hiding the randomizing

If you're intending to hide the interface so that you give scriptX a list of arguments and it returns back a randomized list similar to crunch, then wrapping this in an alias or a shell script would do the job. You could put the following into a shell script called mycrunch.bash:

#!/bin/bash

crunch "$1" "$2" "$3" | sort -R

Mark it as executable:

$ chmod +x mycrunch.bash

And run it like so:

$ ./mycrunch.bash 3 3 ab

Filtering bogus crunch output

You can use a grep command within the script above to filter those lines out like so:

crunch "$1" "$2" "$3" | grep -vE "Crunch|0" | sort -R

That will take care of omitting any lines that contain the strings "Crunch" or "0".

added 258 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

Method #1 - generate just a random series of strings

You can use tr as a filter toSomething like this will generate all the random output that comes frompermutations of the set /dev/random{a,b} @ 3 strings long, and thenit will shuffle up the output using foldshuf it into what ever length strings you want.

Example

$ tr -dc 'a-c' </dev/urandom | foldprintf -w"%s\n" 3{a..b}{a..b}{a..b} | head -n 3shuf
bccbbb
aab
abb
bccbba
baa
aba
bab
aaa

TheThis is really no different though than using trsort -R command provides. If you're intending to hide the set of charactersinterface so that we want to randomly draw from.you give /dev/randomscriptX provides a random sourcelist of these strings. Thearguments and it returns back a randomized list similar to foldcrunch command limits the strings that are output to strings that are 3 characters, then wrapping this in lengthan alias or a shell script would do the job. The last commandYou could put the following into a shell script called headmycrunch.bash is used here to throttle how many strings we actually generate before stopping.

Every time you run the above you'll be given a random set of strings:

$ tr -dc 'a-c' <#!/devbin/urandom | fold -w 3 | head -n 3
cba
ccb
bcbbash

$ tr -dc 'a-c' </dev/urandom |crunch fold"$1" -w"$2" 3"$3" | headsort -n 3
cbb
acb
cbb
R

Mark it as executable:

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | headchmod -n+x 3
bcc
aca
ccbmycrunch.bash

Method #2 - generate a random listing of all the combinations of characters

And run it like so:

$ printf "%s\n" {a..b}{a..b}{a./mycrunch.b}bash |3 shuf
bbb
aab
abb
bba
baa
aba
bab
aaa3 ab

Method #1 - generate just a random series of strings

You can use tr as a filter to the random output that comes from /dev/random and then fold it into what ever length strings you want.

Example

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
abb
bcc

The tr command provides the set of characters that we want to randomly draw from. /dev/random provides a random source of these strings. The fold command limits the strings that are output to strings that are 3 characters in length. The last command head is used here to throttle how many strings we actually generate before stopping.

Every time you run the above you'll be given a random set of strings:

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cba
ccb
bcb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cbb
acb
cbb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
aca
ccb

Method #2 - generate a random listing of all the combinations of characters

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa

Something like this will generate all the permutations of the set {a,b} @ 3 strings long, and it will shuffle up the output using shuf.

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa

This is really no different though than using sort -R. If you're intending to hide the interface so that you give scriptX a list of arguments and it returns back a randomized list similar to crunch, then wrapping this in an alias or a shell script would do the job. You could put the following into a shell script called mycrunch.bash:

#!/bin/bash

crunch "$1" "$2" "$3" | sort -R

Mark it as executable:

$ chmod +x mycrunch.bash

And run it like so:

$ ./mycrunch.bash 3 3 ab
added 258 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897

Method #1 - generate just a random series of strings

You can use tr as a filter to the random output that comes from /dev/random and then fold it into what ever length strings you want.

Example

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
abb
bcc

The tr command provides the set of characters that we want to randomly draw from. /dev/random provides a random source of these strings. The fold command limits the strings that are output to strings that are 3 characters in length. The last command head is used here to throttle how many strings we actually generate before stopping.

Every time you run the above you'll be given a random set of strings:

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cba
ccb
bcb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cbb
acb
cbb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
aca
ccb

Method #2 - generate a random listing of all the combinations of characters

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa

You can use tr as a filter to the random output that comes from /dev/random and then fold it into what ever length strings you want.

Example

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
abb
bcc

The tr command provides the set of characters that we want to randomly draw from. /dev/random provides a random source of these strings. The fold command limits the strings that are output to strings that are 3 characters in length. The last command head is used here to throttle how many strings we actually generate before stopping.

Every time you run the above you'll be given a random set of strings:

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cba
ccb
bcb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cbb
acb
cbb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
aca
ccb

Method #1 - generate just a random series of strings

You can use tr as a filter to the random output that comes from /dev/random and then fold it into what ever length strings you want.

Example

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
abb
bcc

The tr command provides the set of characters that we want to randomly draw from. /dev/random provides a random source of these strings. The fold command limits the strings that are output to strings that are 3 characters in length. The last command head is used here to throttle how many strings we actually generate before stopping.

Every time you run the above you'll be given a random set of strings:

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cba
ccb
bcb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
cbb
acb
cbb

$ tr -dc 'a-c' </dev/urandom | fold -w 3 | head -n 3
bcc
aca
ccb

Method #2 - generate a random listing of all the combinations of characters

$ printf "%s\n" {a..b}{a..b}{a..b} | shuf
bbb
aab
abb
bba
baa
aba
bab
aaa
added 344 characters in body
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897
Loading
Source Link
slm
  • 379.8k
  • 127
  • 793
  • 897
Loading