Quick actions

cmd+k|ctrl+k

Navigation

Languages

rearrange

Snippet info

Language

Bash

Visibility

public

Author

orph

Created

2024-04-29T22:09:44.218798Z

Updated

2024-04-29T22:09:50.861139Z

#!/bin/bash

# Function to shuffle characters in a word
shuffle_word() {
    local word=$1
    echo $(echo "$word" | fold -w1 | shuf | tr -d '\n')
}

# Function to generate random text from input text
generate_random_text() {
    local input_text="$1"
    local output_text=""

    # Split input text into words
    read -ra words <<< "$input_text"

    # Shuffle each word and append to output text
    for word in "${words[@]}"; do
        shuffled_word=$(shuffle_word "$word")
        output_text+=" $shuffled_word"
    done

    echo "$output_text"
}

# Main function
main() {
    # Read input text from stdin
    input_text=$(cat)

    # Generate random text from input text
    random_text=$(generate_random_text "$input_text")

    # Output the random text
    echo "$random_text"
}

# Run the main function
main
INFO