Sample Header Ad - 728x90

What is the practical purpose of "./" in front of relative file paths (in the output from "find")?

10 votes
3 answers
5768 views
Why are some relative file paths displayed in the form of ./file, instead of just file? For example, when I do: find . I get this output: ./file1 ./file2 ./file3 What is the practical purpose, other than making the path more confusing? It's not like it is preventing me from some accident. Both are relative paths, and cat ./file1 works same as cat file1. Is this behavior coming from find command, or is it some system-wide c library? OK, I understand why using ./file for -exec construct is necessary (to make sure I have ... | xargs rm ./-i, and not ... | xargs rm -i). But in what situation would missing ./ break anything when using -print statement? I am trying to construct any statement that breaks something: touch -- -b -d -f -i find -printf '%P\n' | sort -b -d -f -i Everything works fine. Just out of curiosity, how could I construct a -print statement that would demonstrate this issue?
Asked by Martin Vegter (598 rep)
Aug 9, 2022, 08:10 AM
Last activity: Aug 14, 2022, 03:54 AM