I saw the syntax in this question: Birth is empty on ext4

sudo debugfs -R "stat <$(stat -c %i /home/user/path/to/file)>" /dev/sda5

I know command substitution $() and ``.

I kind of vaguely know the <() and >() syntax.

But I've never seen <$()>.

So what does that do?

  • 1
    I think the < > is being passed to debugfs. – ctrl-alt-delor Feb 22 at 18:14
  • Quotes matter. <$(...)> would be shell syntax (not meaningful or valid, but shell syntax nonetheless) -- but inside double quotes, < and > are literal characters; the shell leaves them alone. – Charles Duffy Feb 24 at 13:16

<$()> would be valid bash syntax for commands that read from a file (< part) where file names are created using command substitution ($() part) that redirect output to some other file (> part). Example:

$ echo text > FILE
$ wc < "$(echo FILE)" > WC_OUT
$ cat WC_OUT
1 1 5

However, in the answer you linked to <$()> is used in the parameters to debugfs. In man debugfs it says:

stat filespec

Display the contents of the inode structure of the inode filespec.


The filespec argument may be specified in two forms. The first form is an inode number surrounded by angle brackets, e.g., <2>

In that case:

sudo debugfs -R "stat <$(stat -c %i FILE)>" /dev/sda5

would be expanded by the shell to the equivalent of this:

sudo debugfs -R "stat <4476834>" /dev/sda5

which is a valid debugfs command. Check it with echo:

$ echo sudo debugfs -R "stat <$(stat -c %i FILE)>" /dev/sda5
sudo debugfs -R stat <4476834> /dev/sda5
|improve this answer|||||
  • 1
    My mind is blown, I didn't check the man page of debugfs since I assumed that no bash command would parse an argument as <123456789>. – Melvin Roest Feb 22 at 18:37
  • 11
    Technically, debugfs is not Bash commad, that is it's not Bash built-in command. It's an external program that could run in all shells, even in these that do not implement < and > and on multiple operating systems. – Arkadiusz Drabczyk Feb 22 at 18:49

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.