Grep Print From Match to End of Line
How to print a line of text starting from the match until the end of line using grep and regular expressions:
Assuming these are the lines of text in a file called data-file.txt:
# data-file.txt
07/10/1988 Directories for test data /storage/server01/datafile.txt
09/23/1954 legacy backup data /storage/server03/magnetic-1954.tar.bz2
You want to output just the file name, which starts from /storage
.
grep -o '/storage.*$' datafile.txt
This will output:
/storage/server01/datafile.txt
/storage/server03/magnetic-1954.tar.bz2