Search code examples
linuxbashunixls

Bash list files as {path + file}


I want to search for a file that has 1033 bytes of size. Therefore, I write ls -lRA, which outputs around 200 files, in around 20 folders. When I grep for the file with ls -lRA | grep 1033 I get one element alone, -rw-r----- 1 root bandit5 1033 Dec 3 08:14 .file2. However, there are 20 files with this name, so finding this one is a hard task.

My idea is to get an output such as -rw-r----- 1 root bandit5 1033 Dec 3 08:14 ./direcctory1/.file2, is it possible?


Solution

  • I suggest to use GNU find. Search from current directory:

    find . -size 1033c -ls
    

    Output (e.g.)

    110578      3 -rwxrwxrwx   1 root     root         1033 Dec  6 10:10 ./direcctory1/.file2
    

    See: man find