Shift Them Up
A program writes to app.log and keeps two older logs beside it. Make room for a new one: app.log.2 becomes app.log.3, app.log.1 becomes app.log.2, app.log becomes app.log.1, and a new, empty app.log takes its place. Nothing that was in the three files may be lost.
Example 1
app.log
today
app.log.1
yesterday
app.log.2
two days ago
ends as
== ./app.log == ./app.log.1 today == ./app.log.2 yesterday == ./app.log.3 two days ago
Constraints
- The folder holds
app.log,app.log.1andapp.log.2, and nothing else
Write it in your browser, against the clock. The model script, with a note on each command it uses, comes after.
More Bash problems
- Sort Into FoldersHard
- TODOs per FileHard
- The Biggest FileHard
- Totals per GroupHard
- Word Count TableHard
- Count the LinesBeginner
- Count the WordsBeginner
- First Three LinesBeginner