To print the line containing a pattern and 2 lines before it, you can use this grep command:
grep -B2 “^Drive” /path/to/my/file
If your input file looks like this:
Backup
Policy
Information
Data
Drive
Size
grep -B2 “^Drive” /path/to/my/file will print this:
Information
Data
Drive
