Quantcast
Channel: A Portal to a Portal
Viewing all articles
Browse latest Browse all 1850

What's the opposite of "cat" ? Another in the "I did not know that" series

$
0
0
Thanks to a friend, Paul Smith, for sharing this.

He had a requirement - to take a list of items ( a text file ) and invert the list.

Initially I thought he meant that he wanted to sort the list, which seemed simple.

Here's a list: -

cat list.txt 

Cat
Rabbit
Dog
Gerbil
Hamster
Horse
Rhino
Hippo
Alosaur


so here's the sorted list: -

sort list.txt 

Alosaur
Cat
Dog
Gerbil
Hamster
Hippo
Horse
Rabbit
Rhino


and here's the reverse sort: -

sort -r list.txt 

Rhino
Rabbit
Horse
Hippo
Hamster
Gerbil
Dog
Cat
Alosaur


but NO, I didn't understand his requirement - he wanted the list reversed BUT not sorted.

Introducing …. TAC

Why tac ? 'cos it's the reverse of cat  :-)

Unix and puns, what's not to like

So here's the list, reversed BUT NOT sorted: -

tac list.txt 

Alosaur
Hippo
Rhino
Horse
Hamster
Gerbil
Dog
Rabbit
Cat


Viewing all articles
Browse latest Browse all 1850

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>