Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #/!bin/bash
- # Example file containing acronyms
- acro_file=$(mktemp)
- printf "Foo\nBar\n" > "$acro_file"
- # Example file containing server names
- server_file=$(mktemp)
- printf "FooServer\nBarServer\nBazServer\n" > "$server_file"
- sed 's/\(.\{3\}\)/\1\t\1/' "$server_file" | # Prepend server names with first three characters and tab
- sort -k1 | # sort based on first column (i.e. acronym)
- join - <(sort "$acro_file") | # merge server_file and acro_file based on first column of both inputs
- cut -d' ' -f2 # keep only full server name
- rm "$acro_file" "$server_file"
Advertisement
Add Comment
Please, Sign In to add comment