Mercurial > hg > toybox
annotate wrappers/tac @ 543:60b97ba66a70
Extensive semi-gratuitous refactoring: factor out common code, handle euid!=uid and egid!=gid cases. (Note: test suite requires root access, possibly container support.)
author | Rob Landley <rob@landley.net> |
---|---|
date | Mon, 12 Mar 2012 23:00:28 -0500 |
parents | 7da386057101 |
children |
rev | line source |
---|---|
411
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
1 #!/bin/sh |
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
2 # HELP usage: tac [FILE...]\n\nPrint input lines in reverse order |
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
3 |
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
4 for i in "$@" |
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
5 do |
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
6 sed -e '1!G;h;$!d' "$i" |
7da386057101
Add three commands that can be done as simple shell scripts (one sed is in, anyway), and don't need to be implemented in C.
Rob Landley <rob@landley.net>
parents:
diff
changeset
|
7 done |