What does <$( )> do

Melvin Roest

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?

Arkadiusz Drabczyk

<$()> 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.

and:

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

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive