0

I'm using debugfs to stat a filename with spaces. The file exists, but I get this message (same message if I change spaces by \ or write the filename between simple quotes):

$ sudo debugfs -R "stat /home/user/This is a test.txt" /dev/mapper/VolGroup00-lv_root
debugfs 1.44.5 (15-Dec-2018)
stat: Usage: stat <file>

If I use this format I get this error:

$ sudo debugfs -R "stat $'/home/user/This\x20is\x20a\x20test.txt'" /dev/mapper/VolGroup00-lv_root 
debugfs 1.44.5 (15-Dec-2018)
$'/home/user/This\x20is\x20a\x20test.txt': File not found by ext2_lookup 

If I use this format I get this error:

$ sudo debugfs -R "stat $'/home/user/This\024is\024a\024test.txt'" /dev/mapper/VolGroup00-lv_root 
debugfs 1.44.5 (15-Dec-2018)
$'/home/user/This\024is\024a\024test.txt': File not found by ext2_lookup 

Is it possible to stat a filename with spaces with debugfs?

0

1 Answer 1

1

stat in debugfs expects exactly one argument (therefore Usage: stat <file>). The string you provided

/home/user/This is a test.txt

is seen as many arguments separated by spaces. The tool supports quoting with double quotes though. This will work:

sudo debugfs -R 'stat "/home/user/This is a test.txt"' /dev/mapper/VolGroup00-lv_root
3
  • Sorry, but I tink that I tested it before and does not work $ sudo debugfs -R 'stat "/home/user/This is a test.txt"' /dev/mapper/VolGroup00-lv_root debugfs 1.44.5 (15-Dec-2018) /home/user/This is a test.txt: File not found by ext2_lookup
    – oml
    Commented Feb 3, 2019 at 11:21
  • @oml Apparently there is no such file but the syntax is now correct. The response shows all spaces in the filename were recognized. Commented Feb 3, 2019 at 11:24
  • Sorry, it was my fault. I had a typo in the filename. You are rigth. It works fine now. Thanks a lot!
    – oml
    Commented Feb 3, 2019 at 11:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .