Questions tagged [tree]
The tree tag has no summary.
118 questions
9
votes
5
answers
2k
views
Is there a command to recreate directory trees?
I created a 'cron' subdirectory in /var/log/ . It is: /var/log/cron
Within /var/log/cron I've created numerous sub-directories to store my log files for cron jobs. I am wondering if there is a way ...
5
votes
2
answers
404
views
How to show directory sizes in tree format with correct values and depth control
I can't solve what I want using the tree, du, or df commands.
I'm using:
du version 9.6
tree version 2.2.1
What I want:
For the current directory, list all directories recursively to a depth of 3, ...
2
votes
0
answers
177
views
using a .info file for tree where comment should be in the same line as file pattern
I know about the .info file functionality with the tree command and would like to use this in one of my bash scripts.
I played around in the terminal and have the following structure:
test
...
-2
votes
1
answer
86
views
list tree of a specific proc
I have a command to list the tree of a specific process number. So I did this:
ps f -u "${USER}" --pid 1234 -eo command,pid,ppid,tty | awk 'NR <= 1 {print; next} !/awk/ && $0 ~ ...
0
votes
1
answer
128
views
Installing tree installed grub - is it something to worry about?
I just installed tree via
sudo apt-get install tree
and my terminal suddenly decided to update grub. Last week, I installed tree, and a similar thing happened. However, when I restarted my PC later ...
4
votes
1
answer
323
views
tree command with 'sort=size' seems imperfect
I'm trying to sort by size:
% tree -axCF --du --sort=size | grep -e '/$'
├── [ 8658884] 2022-10-09-backup/
├── [ 5923934] f24-01-22-backup/
├── [ 5384825] e2023-01-19-backup/
├── [ ...
4
votes
1
answer
554
views
Is there a way to make tree not show the top level?
By default, tree shows this:
$ tree
.
├── Package.resolved
├── Package.swift
├── Sources
│ └── SwiftClientSDK
│ ├── OpenAPI.yaml
│ ├── SwiftClientSDK.swift
│ └── openapi-generator-...
1
vote
1
answer
28
views
Tree display hw, hw.cpp & hw.cpp2 in sub-directories
I would like tree to display the hw files in the sub-directories like this:
.
├── exp
│ └── hw
├── src
│ └── hw.cpp2
└── tmp
└── hw.cpp
$ /usr/bin/tree --noreport . displays all of the files:...
0
votes
1
answer
160
views
Command "tree -J" returns invalid Json
I gave the command tree -J to my machine, and this is a portion of the output it gave:
{
"type": "file",
"name": &...
0
votes
2
answers
2k
views
Using 'TREE' for sub-subdirectories
Is it possible to use tree to create several output files without being cd ~/ into the directory I want to create a tree file?
For example, I have a directory called parent-dir.
Inside of parent-dir ...
1
vote
1
answer
1k
views
tree command to only output file and directory count?
I want to keep only the last line of tree's output or the file+directory count report. Preferably, with the -a switch.
An example output I desire:
585 directories, 37722 files
Is this possible with ...
2
votes
0
answers
53
views
Is it possible to colourise the heading lines on bash tree output?
Say I have a directory structure that looks like this:
foo
|-- bar
| |-- 1
| |-- 2
| |-- 3
| |-- baz
| | |-- 4
| | |-- 5
| | |-- 6
| | |-- moo
| | | |-- 7
| | | |-- ...
3
votes
1
answer
187
views
get field from tree with fzf
I've tried something like this
tree -C | fzf --ansi | awk -F'|' '{print $NF}'
├── repo.git/
│ ├── folder/
│ │ ├── subfolder/
│ │ │ ├── output.0
│ │ │ └── traces.1
│ │ ├── ...
0
votes
1
answer
72
views
Tree. What is the location of the generated text file?
Ubuntu. Tree.
tree -fi /path/to/the/directory >~/file.txt
I see the files in terminal but was under the impression that a text file called 'file.txt' would be generated, but I can't find it.
4
votes
1
answer
4k
views
Autocompletion not working for pass password manager in zsh in linux
I already used pass program for password managing on MacOS with zsh (where the autocompletion worked flawlessly out of the box) and now trying to move on linux on a raspberry pi 4b 4GB, installed zsh ...
4
votes
2
answers
1k
views
How to use the tree command to expand only selected folder(s)?
I'm creating a script that generates a project folder into another folder along with some other module folders. I want to show how the generated project folder structure looks in the final tree but ...
1
vote
0
answers
1k
views
tree command how to omit too many subfolders?
I want to preview the structure of a folder with tree -d. However, some subfolder has too many subfolders, which prevent me to preview the whole tree at a glance, so I want a argument such as --...
4
votes
2
answers
1k
views
Creating .info files to be used with tree
man tree1 states:
-info Prints file comments found in .info files. See .INFO FILES below for more information on the format of .info files.
and further
.INFO FILES
.info files are similiar to ....
3
votes
2
answers
745
views
How to create a file for every directory on a tree?
For the following tree structure:
.
└── dir1
└── dir2
└── dir3
What would be a simple way to create a file (could be empty), for every directory, so the resulting tree will look like:
...
-2
votes
2
answers
2k
views
tree command with icons
We all love the tree command, but it would be amazing to have the icons next to the files, as both the file browser of VSC or Color Ls have.
Does anyone know any way to implement it?
2
votes
1
answer
954
views
Display `grep -lr` results as a tree
I'm searching a large number of text files which are organized in various subdirectories. I can run a command such as grep -lr foobar ./, and I get results like the following:
./dirA/dirA.A/abc.txt
./...
0
votes
1
answer
542
views
How Do I Get `tree` to Selectively Exclude Contents of Directories?
I'm using tree on a directory which has -- among other things -- some Audacity projects in it. Each Audacity project is some file X.aup, along side a directory X_data, which contains a few sub-...
3
votes
1
answer
96
views
Print structured list to command-line (tree like)
If I have a text-file with a structured list like this:
#linux
##audio
###sequenzer
####qtractor
###drummachine
####hydrogen
##scores
###lilypond
###musescore
##bureau
###kalender
####calcurse
###...
2
votes
1
answer
4k
views
What does the output `d?????????` in `ls -l` mean? [duplicate]
What is the situation why ls -l returns a list of subdirectories in the form below?
d????????? ? ? ? ? ? Subdirectory
A tree launched on that directory returns 0 directories, 0 files for ...
0
votes
3
answers
660
views
tree command: Can you prevent the formatting dependancy on the final item?
I am using tree and diff to compare a local directory with a USB backup version of the same directory, and to identify noteworthy / discardable differences.
$ cd home/dir/
$ tree --charset=ascii -af . ...
0
votes
0
answers
64
views
What does this wecho command do?
I found a script that makes a file list. The list looks like this
/home/usr/example_directory
/home/usr/example_directory/file1.txt
/home/usr/example_directory/file2.txt
/home/usr/different_directory
/...
0
votes
1
answer
6k
views
ls to recurse, showing full path
There are obviously many ways to do the same job in Linux, but I recently needed to for i in xxx through a list of each item, recursively in a tree. I found a solution with tree by doing tree -fail (...
0
votes
1
answer
52
views
tree: Is there a way to maintain visibility of outer level directory labels when scrolling?
When you generate a tree for a large directory base with innumerable sub-directories and associated files, with -a option, often you get a large file with thousands of lines. While traversing the tree ...
0
votes
1
answer
67
views
How to detect which files are created when running a command
I'm trying to understand what files or build artifacts are created by the build system of a C++ project.
There are 3 steps to building this project:
./autogen.sh
./configure
make
Is there a way I ...
-1
votes
1
answer
1k
views
Directory structure for large amount of files [closed]
I have millions of files which filenames are SHA256 hashes of the content. Due to performance reasons I do not want to store them in a single directory. My idea is to have directory structure based on ...
0
votes
1
answer
3k
views
How to use tree with grep and find to locate files by name?
How can I use tree and either grep or find in conjunction to find, for example, csv files using ".csv" as a file extension:
├── ./Videos
├── ./vscode
│ ├── ./vscode/foo.csv
│ ├── ./...
4
votes
1
answer
1k
views
Efficiently turn a directory tree into a new filesystem on zfs
I "inherited" management of a system, whose "/opt" (and some other large directory trees) are stored in the root file system.
My wish now is to create a new filesystem in the rpool ...
0
votes
1
answer
186
views
Print only files, directories containing files and empty directories
I am trying to index some LTO tapes (and some hard disks as well) and would like a simple output, stored in a text file. Something like the example below:
...
/home/norg/Desktop/empty\ dir/
/home/norg/...
2
votes
0
answers
629
views
Show files modified after a particular date ('find') in hierarchical format ('tree')
I'm trying to view files modified before or after a certain date using the hierarchical output of the Unix tree command.
For example, I know that one can use tree to sort files chronologically and ...
0
votes
1
answer
3k
views
How to find files greater than a size in linux [duplicate]
I want to find user, size, modified date and full file path of all files in sub-directories starting from a dir. I have got to following so far:
nohup sudo \
tree /work/mydir \
-sufiD \
--noreport \
--...
0
votes
2
answers
375
views
Tree structures and directories [closed]
I need to draw the tree structure of the following code.
cd /; mkdir a b c a/a b/a; cd a; mkdir ../e ../a/f ../b/a/g; cd../b/./; mkdir /a/k a/b ../a/./b /c
I know that: cd /; (goes to root) , mkdir ...
2
votes
1
answer
1k
views
`tree` horizontal display
Is there an alternative to tree command (or some way using the tree command itself) to print the directory structure horizontally?
Quite often, I have a tree structure, for which I have to scroll a ...
1
vote
2
answers
2k
views
What is a "path name component"? [duplicate]
I am not sure I correctly understood what is a path name component (or perhaps better written; path name-component) which I understand to be commonly abbreviated simply as "component" in the Unix &...
1
vote
2
answers
158
views
What is the most basic "depth" of any "container file"?
I use the term "container file" to describe any file which practically contains one file or two or more files. Some examples would be a tar archive or a directory.
Let's say I open a tar archive with ...
5
votes
5
answers
11k
views
How to draw a continuous line in terminal?
I've been searching for this for a while and didn't get a satisfactory answer for it.
I've taken this screenshot from the output of Gnu/Linux's tree command.
I want to know how to draw or print lines ...
2
votes
3
answers
2k
views
List files recursively, in alphabetical order and without lines that show exclusively folder names
How to list files recursively, in alphabetical order and without lines that show exclusively folder names?
For example, I can get the following output with tree --dirsfirst -fihan * -o filelist:
00.-...
2
votes
2
answers
652
views
Easiest way to get `+` indented `tree` output
I need to replace indentation in tree output with + signs so that instead of this:
$ tree --noreport dir
dir
├── dir1
│ ├── file1
│ └── file2
└── dir2
├── file1
└── file2
it'd print this:
...
1
vote
1
answer
295
views
Confused about "tree" not finding a file
Why the last tree is not finding fstab?
tree /etc -P fstab --prune
/etc
└── fstab
0 directories, 1 file
.
tree /etc -P fsta* --prune
/etc
└── fstab
0 directories, 1 file
.
tree /etc -P *...
2
votes
1
answer
2k
views
du + tree command (without tree installation)
is there a nice way to combine:
ls -R | grep "^[.]/" | sed -e "s/:$//" -e "s/[^\/]*\//--/g" -e "s/^/ |/"
(displays directory as tree)
with
du -h ... (for each listed dir)
Without installing any ...
2
votes
2
answers
4k
views
Exclude subdirectory pattern for the tree command not working
I'm trying to use the tree command to list my current git directory.
I want to exclude every files that match a gitignore pattern.
The solution found here seems promising.
Unfortunately it seems ...
0
votes
1
answer
161
views
Copying files from specific subsubdirectories based on subdirectory name into single directory then renaming
So here's an excerpt of my directory tree:
|-- 20070214_014700.a
| |-- info
| |-- processed
| |-- HH.EL..BHZ
| |-- AZ.AS..HHZ
| |-- (hundreds more)
| |-- raw
| ...
0
votes
1
answer
231
views
How to get an output results as text to more than one location at once? [duplicate]
Is there a way that I can get a resulted output to multiple locations at the same time. ls -RsgorCh >> /Users/User1/Text1.txt will print the output as a text file in the given location. I want ...
0
votes
2
answers
876
views
How to shorten image sequence output in tree command?
I'm in a directory where running tree command produces something like this:
├── directory1
│ └── image_sequence
│ ├── image.0001.jpg
│ ├── image.0002.jpg
│ ├── image.0003.jpg
│ ...
3
votes
1
answer
4k
views
Using tree with tar.gz file without extracting contents
I am wondering if it's possible to output the contents of a tar.gz file using tree without having to extract the contents of the file to a temp directory then using tree with that directory.
I know ...
2
votes
2
answers
958
views
How to convert `iptables -S` output to a breadth-first listing
I'm looking for a program that takes the output of iptables -S and converts it to a breadth-first listing.
Why? I'm doing some work on a router using VyOS where several layers of tables are pre-...