I have the following line of code that works wonders. I just don't completely understand it as I am just starting to learn regex. Can you help me understand exactly what is happening here?
find . -type f | grep -v '^\.$' | sed 's!\.\/!!'
I have the following line of code that works wonders. I just don't completely understand it as I am just starting to learn regex. Can you help me understand exactly what is happening here?
find . -type f | grep -v '^\.$' | sed 's!\.\/!!'
Here is what it is doing:-
find . -type f
Finds all the files in a directory
grep -v '^\.$'
Removes files starting with . and also ending with . (since you are using -type f, this is not necessary)
sed 's!\.\/!!'
Removes first occurence of ./ from the output.
That actually means find all files recursively down the tree rooted at the current directory.
Thanks. I knew what
find . -type f
was for, but it was part of the line of code, so I kept it in. Thanks again for explaining the regex part!
You can shorten the command to:
find . -type f | sed 's!./!!'