If you would like to do a similar regex procedure in sed :
sed -n 's/.* \([^\s]\{2,\}\.HHF\)/\1/p' log.txt > files.txt
The default behaviour of sed is to print out each line in the file you give it (in this case, log.txt). The -n
flag turns that behaviour off. The s/REGEXPATTERN/REPLACEMENT/
command will find lines with a substring matching REGEXPATTERN
and replace it with REPLACEMENT
. An example of a helper command in sed to do fancy replacement is the \#
command, where #
is an integer, which replaces the substring of the line matching the #
-th part of the REGEXPATTERN
in parentheses, starting with 1. In this case, it will replace the entire line by just the part of the line that has at least two non-whitespace characters followed by .HHF
. Finally, the p
command prints out the resulting modified line, in this case just the filename. Then, we pipe the output with >
to a text file that will have all your filename stored, one per line. This sed command assumes that your files have at least two characters before the .HHF ending, and it assumes that the filenames will be preceded by at least one space.