PES INSTITUTE OF TECHNOLOGY AND MANAGEMENT. UNIX PROGRAMMING 18CS56 TOPIC:-PREVIEW OF TREE COMMAND.
WHAT IS TREE COMMAND?. TREE – USED TO DISPLAY THE CONTENTS OF A DIRECTORY AS AN INDENTED TREE. SYNTAX :- $tree [options] With no arguments, tree lists the files in the current directory. When directory arguments are given, tree lists all the files or directories found in the given directories each in turn. Upon completion of listing all files and directories found, tree returns the total number of files and directories listed..
COMMON TREE COMMAND OPTIONS. –help : Outputs a verbose usage listing. –version : Outputs the version of tree. -a : All files are printed. By default, tree does not print hidden files (those beginning with a dot `.’). In no event does tree print the file system constructs `.’ (current directory) and `..’ (previous directory). -d : List directories only. -f : Prints the full path prefix for each file..
OPTIONS. - i : Tree will not print the indentation lines. Useful when used in conjunction with the -f option. -l : Follows symbolic links to directories as if they were directories. Links that would result in a recursive loop are avoided. -x : Stay on the current file system only, as with find - xdev . -P pattern : List only those files that match the wild-card pattern..
EXAMPLE 1 : Display the tree hierarchy of a directory $ tree -a ./GFG OUTPUT :.
EXAMPLE 2 : List files with entered pattern $ tree -P sample* . Output :.
3. List those directories which have greater ‘N’ number of files/directories $ tree -- filelimit 3 ./GFG 4. List files with their permissions. $ tree -p ./GFG 5. Prints the device number to which the file or directory belongs . $ tree --device ./GFG 6. Prints the output by last modification time instead of alphabetically. $ tree -t ./GFG - THANK YOU.