$ cat order.txtroger shaharmin van buurenfpga vhdl arduino c++ java gridgain$ tac order.txt > inverted_file.txt$ cat inverted_file.txtfpga vhdl arduino c++ java gridgainarmin van buurenroger shah
# Generate a newline delimited sequence of 1 to 10$ seq 1012345678910
# Use - to read from stdin.# vim has a delay and annoying 'Vim: Reading from stdin...' output# if you use - to read from stdin. Use --not-a-term to hide output.# --not-a-term requires vim 8.0.1308 (Nov 2017)# Use -E for improved ex mode. -e would work here too since I'm not# using any improved ex mode features.# each of the commands I explained above are specified with a + sign# and are run sequentially.$ seq 10 | vim - --not-a-term -Es +'g/^/m0' +'%p' +'q!'10987654321# non improved ex mode works here too, -e.$ seq 10 | vim - --not-a-term -es +'g/^/m0' +'%p' +'q!'
# If you don't have --not-a-term, use /dev/stdinseq 10 | vim -E +'g/^/m0' +'%p' +'q!' /dev/stdin
# POSIX compliant (maybe)# POSIX compliant ex doesn't allow using + sign to specify commands.# It also might not allow running multiple commands sequentially.# The docs say "Implementations may support more than a single -c"# If yours does support multiple -c$ seq 10 | ex -c "execute -c 'g/^/m0' -c '%p' -c 'q!' /dev/stdin
# If not, you can chain them with the bar, |. This is same as shell# piping. It's more like shell semi-colon, ;.# The g command consumes the |, so you can use execute to prevent that.# Not sure if execute and | is POSIX compliant.seq 10 | ex -c "execute 'g/^/m0' | %p | q!" /dev/stdin