Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Solution for reversing a linked list in bash
#!/usr/bin/env bash
# Where input.txt is:
# a>b
# b>c
# c>d
# d>e
paste -d '>' <(< input.txt | cut -d'>' -f2 | tac) <(< input.txt | cut -d'>' -f1 | tac)
# Output:
# e>d
# d>c
# c>b
# b>a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.