Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to strip leading "./" in unix "find"?

Tags:

find

unix

strip

People also ask

What does RM {} do?

The {} bit is the placeholder for the exec command. Whatever files are found by find are inserted in place of the brackets. The + means to build up a long list of the found files and call the exec on all of them at once instead of one at a time, like the more traditional -exec {} \; variant.

How do I delete a directory in find?

How do I find and delete directories based on find command output on Linux or Unix-like system recursively? The -delete option remove the DIRECTORY(ies), if they are empty. You need to use the -exec option to delete all directories and its contents.

How do I show the first 10 lines of a file in Linux?

To look at the first few lines of a file, type head filename, where filename is the name of the file you want to look at, and then press <Enter>. By default, head shows you the first 10 lines of a file. You can change this by typing head -number filename, where number is the number of lines you want to see.


Find only regular files under current directory, and print them without "./" prefix:

find -type f -printf '%P\n'

From man find, description of -printf format:

%P     File's name with the name of the command line argument under which it was found removed.


Use sed

find . | sed "s|^\./||"

If they're only in the current directory

find * -type f -print

Is that what you want?


it can be shorter

find * -type f