Questions tagged [stat]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0
votes
1answer
29 views

partition size vs file system size

I am writing a c++ program that I need to get partitions and hhd's total, free and used space. I'm so confused with all commands and codes that can be used to get these data from system and all ...
0
votes
0answers
14 views

dumpe2fs vs stat command

As metioned here: https://linux.die.net/man/8/dumpe2fs , dumpe2fs prints out superblock and size of blocks and.. like below : root@swkb-dev2:/home/heydari.f# dumpe2fs -h /dev/sda1 dumpe2fs 1.44.1 (...
0
votes
0answers
63 views

Couldn't stat remote file: No such file or directory message inside sftp prompt while doing “ls” or “mget” operation

I am facing a strange problem while using sftp via a shell script.  Here's the transcript of sftp code: sftp> lcd source_folder sftp> cd target_folder sftp> mget -p *_XXXX.dat ...
1
vote
1answer
18 views

How are minor device numbers assigned for unnamed/non-device mounts (major number 0)?

I generally get how the whole major/minor device number thing works for a given device (though please correct me if I'm way off here), and how a major device number essentially relates to a class of ...
0
votes
0answers
33 views

Inconsistent st_blocks and st_size values for inaccessible file

I have a small text file (some metadata redacted) -rw-r--r-- 1 **** **** 17198 Sep 29 2019 230999.txt But it can't be viewed % cat 230999.txt cat: 230999.txt: Attribute not found I'm not sure ...
0
votes
1answer
29 views

I did something to my bashrc or something in UNIX, not listed in sudoers file anymore and can not get access to directories

I am using REDHAT/CENTOS 6.5. I used to have access to directories, but now when I try to go into them after I rebooted by UNIX, it tells me that permission is denied. Using stat command on these ...
1
vote
2answers
69 views

Find the age of the oldest file in one line

I tried stat -c %Y ./* 2>/dev/null | awk -v d="$(date +%s)" 'BEGIN {m=d} $0 < m {m = $0} END {print d - m}' to find the age of the oldest file in the current directory, and I get a number in ...
0
votes
0answers
17 views

Viewing disk activity per disk and per process

I'm trying to see the disc activity per process and disk. The output of iotop is perfect, but it is over all volumes. I found a similar question here iotop but for particular disk? dated 6 years ago ...
0
votes
1answer
39 views

Using stat for time or date -r?

I have listed properties of a folder this way stat -c $'-------------- File: %n Size: %s Owner: %U Group: %G Permissions: %A' but I am having ...
0
votes
1answer
50 views

How do I account for a variable number of extra arguments in a bash script?

It is set up so that $1 is the flag for what the program is going to do, $2 can be a username or anything else. This works great except for one thing: I have to be able to add a comment to a user, and ...
2
votes
0answers
92 views

Portable way of finding files whose birth date is after a given timestamp

According to How to find creation date of file?, in Linux filesystems, such as ext4, Btrfs and JFS, that store the file creation time (aka birth time), it is possible to display the file birth time (...
0
votes
0answers
19 views

How do NFS (and other file sharing) implementations guarantee file stat uniqueness?

The SUSv4-2018ed have the following 2 paragraphs in the specification for <sys/stat.h> header: Note that st_dev must be unique within a Local Area Network (LAN) in a ``system'' made up of ...
0
votes
1answer
144 views

Change file “Birth date” for ext4 files?

Is it possible to change a file "Birth date" (according to the stat file "Birth" field)? I can change the modification/access time with touch -t 200109110846 file, but can't find the corresponding ...
3
votes
2answers
486 views

How to use stat or bash to check whether FILENAME refers to a file

Does the stat command offer, or does bash offer, a straightforward way to check whether FILENAME refers to a file rather than, say, a directory? Using bash and stat, here is my ugly solution: if ...
1
vote
2answers
128 views

How to get difference between 2 dates in Linux?

I know this is a common question, but I do not understand how the solutions provided work. Everyone advises to change the date to seconds from the epoch and then divide by (24 * 3600) to get the ...
0
votes
0answers
15 views

stat command unable to update the modified Time for a mounted file, but when mounted through shell , stat works

I am using stat command to check if the mounted file got updated recently, when I issue mount command on bash i can see stat works, where any modification to the mounted file updates the Modify time ...
2
votes
1answer
1k views

Get mtime Epoch timestamp with milliseconds from `stat`

If I'm using stat to display the mtime, I get a date with milliseconds: $ stat -c '%y' test.log 2019-07-04 14:32:10.730059167 +0200 However, if I want to display the Epoch timestamp, I don't get ...
0
votes
2answers
112 views

Chaining find exec and a while loop

I'm trying to stack a find command so that the results it returns only contains files with "warning:" or "error:" text within them. I also require those results in a specific format so I'm using exec ...
1
vote
1answer
72 views

Stat -c command in UNIX

I am using the stat commands to show information of all files in a directory, by using the below commands in a script: stat -c"%n|%s|%y" <FOLDER>/* | sed -r 'h; s/\|.*$//; s/^/wc -l </e; G;...
2
votes
1answer
611 views

Why is st_blocks always reported in 512-byte blocks?

I was debugging a fuse filesystem that was reporting wrong sizes for du. It turned out that it was putting st_size / st_blksize [*] into st_blocks of the stat structure. The Linux manual page for stat(...
-2
votes
1answer
107 views

Bash Script general questions [closed]

The first part of what i am mucking around with simply creates a folder entitled command_manuals that contain text file copies of all the commands available at the bash shell, the filenames which are ...
1
vote
1answer
205 views

Translating Linux stat(1) command into BSD stat(1) command

Background CLion's remote project feature currently doesn't support FreeBSD as a remote host OS, but I want to do some hacking and see if it works. By reading the log file, I think I have spotted (...
3
votes
1answer
424 views

Can bash read the “Date Added” of a file/directory?

With programs like stat you see access, modify and change, but with Finder on macOS there is a "Date Added" field. Can I get the "Date Added" for a file or directory displayed in the Terminal, like ...
0
votes
0answers
505 views

How do i capture /proc/<pid>/stat file of a process | linux kernel

As you may know, the /proc/stat file contain the numbers of ticks the different CPU's have spent their time. Same goes to /proc/pid/stat where the tics are measured based on pid (process id) But when ...
1
vote
2answers
385 views

modify time for extracted folder

I just (today is 31-jan-2019) downloaded some random source.tar.gz and extracted it. When I do stat on the resulting folder, I see: Access: 2019-01-31 10:37:26.308991485 +0100 Modify: 2018-11-18 00:...
6
votes
2answers
158 views

Why does GNU Core Utilities stat (including du and ls) report the following sizes (ext4 in GNU/Linux)?

If I have the following contents in a directory: empty_dir: Empty directory. empty_file: Empty file. one_char: File consisting of one character. several_blocks: File consisting of several blocks (but ...
0
votes
3answers
86 views

Using find to list directories that haven't been accessed since a certain date?

Using the stat command one can see and format the last date a directory was accessed. The adate Is it possible to use find to find the directories that were changed before a certain date using a ...
2
votes
1answer
572 views

How to use istat on AIX like stat on Linux distributions

In Linux, I use the following command to show this output: find /backup/$INSTANCE/tsm/* -exec echo '"{}" ' \; | xargs stat --printf "chown %U:%G '%n'\nchmod %a '%n'\n" >> /tmp/permissions.txt ...
6
votes
2answers
157 views

Is it normal that bash stat() and access() much, before commands?

Running strace on the bash shell that is instructed to run mkdir provided this output which shows lots of stats prior to execve the actual mkdir binary: BASH$> strace -f sh -c "bash -c \"mkdir /...
-3
votes
1answer
476 views

List files that are larger than 100 kB

I would like to list all the files in ~ whose size is greater than 100 kB but without using the find command. I need to do it with stat.
1
vote
1answer
198 views

Inode Timestamp Plus/Minus Interpretation

What does +0200 mean after the Access/Modify/Change timestamps? File: task-system.md Size: 197 Blocks: 24 IO Block: 4096 regular file Device: 33h/51d Inode: 14155787 Links: ...
1
vote
2answers
179 views

How can I use 'stat' to detect a new file and then move it to a different directory?

Ultimately I want to detect a new backup file being dropped into a directory and then move that new file to another location for other operations. This needs to work when there is nobody logged into ...
0
votes
1answer
868 views

What can f_bsize be used for? (Is it similar to st_blksize?)

stat() on a file, returns several fields including st_blksize. This is documented as "the 'preferred' block size for efficient filesystem I/O". The value is not used as a unit for other stat() ...
-1
votes
1answer
185 views

Command-line Equivalent to MacOSX stat -f “%m%t%Sm %N” on Linux?

I need to extract the timestamp of when a file has been created modified for the first time. The files are on a server and can be accessed from MacOSX via sshfs, as well as from a Ubuntu server. Under ...
0
votes
1answer
424 views

mounted g_mass_storage doesn't delete files

I'm having a strange problem with g_mass_storage gadget where deleted files from the PC are not 'actually' being deleted, which causes further problems when indexing. Here is the procedure: mount ...
-1
votes
2answers
221 views

What does `stat -c '%B' *` mean? [duplicate]

stat -c '%B' * reports the same number 512 for each file. What does %B mean? I don't understand the manual: %B - The size in bytes of each block reported by ‘%b’ Is it related to my block size: $ ...
0
votes
1answer
68 views

How can I find the three largest files under a directory? [duplicate]

https://unix.stackexchange.com/a/240424/674 shows a way to find the three most recent changed files (directly or indirectly) under a directory. find . -type f -exec stat -c '%Y %n' {} \; | sort -nr | ...
0
votes
1answer
59 views

How can I separate information into fields in both input and output?

$ stat -c "%Y#%n#%y" * | awk -F'#' "BEGIN {OFS=\"|\"} NR==1,NR==3 {print \$2 \$3}" directory1/Blum2017-12-22 22:33:38.644178442 -0500 dir2/Ciolli2017-12-22 21:53:51.769368496 -0500 Dar2017-12-06 13:...
0
votes
1answer
132 views

df and stat -f difference in blocks count for ext4 filesystem on LVM

[yotsu@fedora ttyid:2 czw maj 10 19:25:32 ~]$ df -B4K /dev/mapper/fedora-home System plików 4K-bl użyte dostępne %uż. zamont. na /dev/mapper/fedora-home 625612 27690 561212 5% /home [...
0
votes
1answer
1k views

What is file block size in Linux?

I want to get file block size of two files, using stat struct. In internet, they say file block size is affected by which device is using. If that is right, does block size of all files in same ...
1
vote
1answer
74 views

What is th difference betwen stat -c %B and stat -c %o? [duplicate]

For academic purposes im trying to demonstrate internal fragmentation of a file. As i understand it, internal fragmentation can be shown as a difference between the size of file and the size of all ...
1
vote
1answer
558 views

Difference between blocks from filefrag and stat

I have created file named sometext with random data inside. I wanted to check metadata of this file using several programs. I have used filefrag and stat program. kd@kd-VPCEB2S1E ~/Downloads $ stat ...
0
votes
2answers
377 views

Using ls and stat [closed]

I have written this script, however the output is not correct. It returns stat cannot stat no such file or directory. The file format is Living Room-20180418-0955588134.jpg Any help will be ...
1
vote
1answer
120 views

The BSD's stat option equivalent to `%y` in GNU

There's an option %y which state the last modification time %y time of last data modification, human-readable BSD's stat could list verbose information as $ stat -x Foo File: "Foo" ...
38
votes
1answer
3k views

What is a “weird file”?

An application I am using will not start with this user message: [Errno 13] Permission denied: '/home/sleblanc/.config/app/.config When I used ls, the file showed up as such: ?--------- 1 root root ...
0
votes
2answers
123 views

A Sparse Format from command stat

I'd like to check the status my directories $ ls Foo Bar Zoo Check their status $ ls | xargs stat -x File: "Zoo" Size: 384 FileType: Directory Mode: (0755/...
7
votes
1answer
945 views

File name too long error with command 'stat'

I retrieve a booklist after seaching the python books in home directory using this command on OSX: find ~ -type f -iregex '.*python.*\.pdf' the booklist ... .../Computing/Python/...
-1
votes
2answers
574 views

ls -s uses wrong block size

Ubuntu linux: ls -s disagrees with du & stat for the number of blocks used by a small file. ls -s ../nc2/.git/logs/refs/heads/ total 4 du ../nc2/.git/logs/refs/heads/ 8 ../nc2/.git/logs/...
1
vote
2answers
157 views

Creation time anomaly

I need to know the creation time of a file. I tried to run the stat filename command. But my fs does not store file creation time as metadata. [root@s1 XYZ]# stat ./px/cd/78/...
5
votes
2answers
364 views

Meaning of statement that 'getcwd functions work correctly' in FreeBSD man page for mount_nullfs?

In FreeBSD, man mount_nullfs states that: The primary differences between a virtual copy of the file system and a symbolic link are that the getcwd(3) functions work correctly in the virtual ...