How can i reverse a line in a file in Order
Input file :
123 500 1000 LOAN GOD 10000 01000
321 005 0001 NAOL DOG 00001 00010
Super User is a question and answer site for computer enthusiasts and power users. It only takes a minute to sign up.Sign up to join this community
perl -lne 'print scalar reverse' < my_file.dat
You can use the
tac inputFile > outFile TAC(1) NAME tac - concatenate and print files in reverse SYNOPSIS tac [OPTION]... [FILE]... DESCRIPTION Write each FILE to standard output, last line first. With no FILE, or when FILE is -, read standard input.
There is no simple command to do that in the Single Unix Specification. If, however, you are able to go beyond what Unix provides, you can install
tac. In fact, one of those might very well already be installed on your system, despite the fact that they are not part of Unix.
Obviously, since they are not part of Unix, you should never depend on them being there.
perl -n -e "print reverse split //, $_"