Fd: Uniform output format when searching a parent directory

Created on 13 Oct 2017  ยท  10Comments  ยท  Source: sharkdp/fd

(courtesy of @iology in #102)

Consider this directory tree:

> tree
.
โ”œโ”€โ”€ dir1
โ”‚ย ย  โ”œโ”€โ”€ file1
โ”‚ย ย  โ””โ”€โ”€ file2
โ””โ”€โ”€ dir2
    โ”œโ”€โ”€ file3
    โ””โ”€โ”€ file4

2 directories, 4 files

Now, go to dir1 and perform a search in the parent directory:

> cd dir1
> fd '' ..
.
../dir2
../dir2/file3
../dir2/file4
file1
file2

The results are correct, but it would be more helpful if the output would look like this (in some order):

> cd dir1
> fd '' ..
../dir1
../dir2
../dir2/file3
../dir2/file4
../dir1/file1
../dir1/file2
feature-request

Most helpful comment

Ooops, while fixing #82, I inadvertently implemented this feature. :P

All 10 comments

How about making this a flag like --tree? That would allow the tree structure when wanted but then it will default to the original output by default. It's often easier to work with the default output when scripting.

@Doxterpepper: It's often easier to work with the default output when scripting.

Examples?

Normally when I'm searching for a file I am intending to do something with it such as edit it with a text editor. If the output is like the original output it is easier to copy and paste into the next command, or to include it in a script to perform some action on each file. A crude example would be:

for file in $(fd 'foo.txt' .)
do
  echo 'some change' >> $file
done  

I think the tree output is great for humans to read, perhaps the tree output could be default unless something like --plain is given. In either case the option for basic output would be good in my opinion.

@Doxterpepper I still don't see why you don't want "../dir1/file1" (instead of "file1"), while you still tolerate "../dir2/file3". And to copy/paste "file1" is just a double click.

NOTE: Your example use ".", not "..".

I think I misunderstood the description, I thought the suggestion was to include tree style output with ascii decorators and all. Disregard my comments above.

understanding the requirements better now, would anyone oppose me taking this on?

No problem, I haven't started on this one.

Ooops, while fixing #82, I inadvertently implemented this feature. :P

Ooops, while fixing #82, I inadvertently implemented this feature. :P

Sounds good :smile:. Would you like to open a PR for that?

Sounds good ๐Ÿ˜„. Would you like to open a PR for that?

Some superfluous slashes and dots in the output is giving me a headache, #112 only solves part of the problem. (Linux) I need to fix that first. ๐Ÿค•

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ChengCat picture ChengCat  ยท  3Comments

ariecattan picture ariecattan  ยท  3Comments

codyro picture codyro  ยท  4Comments

sharkdp picture sharkdp  ยท  4Comments

mrzool picture mrzool  ยท  4Comments