0

Locate search is not limitable to current directory:

I am trying to learn so I decided to write this script

cd /usr/share/doc && ls -R | grep "\.html" | sudo tee htmldoclist.txt

Then I want to pipe the doc list into locate command similar to

locate $(head -n 1 htmldoclist.txt)

but I want to use cat.

I want to save the output of this to hlinks.txt and use sed to append file:// to line starts with pipe to sed as follows:

| sed -e 's/^/file:///g'

I expect to create a bunch of terminal hyperlinks for my documentation files stored in /usr/share/docs

1 Answers1

1

It looks like find would be more appropriate for the task, it will give your the list of files and filter them and then you can use sed:

find /usr/share/doc -iname '*html' | sed  's|^|file://|'

But find does a lot more, it can also format the output for you:

find /usr/share/doc -iname '*html' -printf 'file://%p\n'