

This command displays only the contents of the directory just down one level which means it cannot display other subdirectories and its contents and also hidden files.Ĩ. To list the files and directories in the current directory use the following command.

To list the contents of the directory using grep command run the following command. This command is used for searching text files using regular expressions. Use the following command line to list the files and directories stat -c '%A %n' * 6. With the help of this command, we can find the properties of file such as file size, permissions, modified date, etc. This command is used to display the information of files and filesystem. If you want to search only the directories and skip the file names use the -type d option as shown below.
Unix grep directory how to#
How to List only Directories Using Find Command The dot (.) symbol indicates the current working directory. To display all files which are present in the current working directory, use the following command.

You can search files by name, extension, group, modification date, permissions etc. The find command helps us to look up for files for which we know only the approximate names.In simple words the find command searches for a file in the current working directory and recursively through the subdirectories that matches the given search criteria. The output will display both files and directories. To display the contents of current working directory run the following command. It will display the given parameters in the specified format or execute the command depending on the option specified. This command is used for formatting and printing text. In the above output, d indicates directories. To print the detailed information of each file and directory use the -l command-line option. The forward slash in the above output indicates the directory and others indicate files. The dir command is used to list the contents of the directory. we can print only the directory names by using the following command. While using the long listing option –l we can grep the lines that starts with d. This option allows us to grep directories by ‘grep’ing lines that ends with forward slash. The -F option adds a trailing forward slash. To list directories in the Long listing format use the -l option.
