Stack Exchange network consists of 183 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Bash
#!/bin/bash taceval `tac $0 | head -n 4 | xargs -i sh -c 4` "eval&& {}" exit echo 'Line1' ; echo 'Line2' ; echo 'Line3' ; echo 'Line4' ;
Output:
Line4 Line3 Line2 Line1
#!/bin/bash tac $0 | head -n 4 | xargs -i sh -c "eval {}" exit echo 'Line1' echo 'Line2' echo 'Line3' echo 'Line4'
#!/bin/bash eval `tac $0 | head -n 4` && exit echo 'Line1' ; echo 'Line2' ; echo 'Line3' ; echo 'Line4' ;
The first line of this program causes it to run the last four lines backwards:
#!/bin/bash tac $0 | head -n 4 | xargs -i sh -c "eval {}" 2>/dev/null exit echo 'Line1' echo 'Line2' echo 'Line3' echo 'Line4'
#!/bin/bash tac $0 | xargs -i sh -c "eval {}" 2>/dev/null exit echo 'Line1' echo 'Line2' echo 'Line3' echo 'Line4'