Created
March 4, 2019 06:02
-
-
Save ben-ng/958e1d4b559be7a32a33e06355511ed7 to your computer and use it in GitHub Desktop.
Solution for reversing a linked list in bash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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