Skip to main content

Questions tagged [stat]

The tag has no usage guidance.

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

stat not giving birth datetime in cluster

with the command stat file.txt I get Access: 2024-06-10 14:55:36.254879000 +0300 Modify: 2024-06-10 14:55:36.254879000 +0300 Change: 2024-06-10 14:55:36.254879000 +0300 Birth: - I work in a cluster ...
Dimitris Tsiaousidis's user avatar
0 votes
0 answers
23 views

Debug log from system call stat() is not printed

I want to build the 4.18.1 linux kernel and add a debug log in several places: in clone and stat system calls. I added the line printk(KERN_INFO "syscallstat"); at https://elixir.bootlin.com/...
ibse's user avatar
  • 341
-1 votes
2 answers
112 views

Is this "stat [option]... inode number..." possible?

Is it possible to use stat for retrieving meta data of File1 by passing File1's inode number as an argument to stat instead of the file name? stat [option - any doing this?] [inode number of File1] ...
futurewave's user avatar
1 vote
4 answers
610 views

Bash script - check if any files changed recently

I am writing a script which needs to check if any of the files in a given directory have been modified recently. I thought I could simply use find, however it reports success even if it doesn't find a ...
symcbean's user avatar
  • 5,821
0 votes
1 answer
99 views

How to determine when KVM vm was created?

OS is Debian. Not asking about uptime of course, but I would like to determine when vm was created and/or first booted. Normally you can do something like: stat / and check birth time, but for a kvm ...
cat pants's user avatar
  • 487
0 votes
1 answer
360 views

After `su user`, getting `fatal: failed to stat : Permission denied` with `git push`

There's a lot of setup for this question: I've got a host (rpi5.local) with 2 user accounts: pi and cake. I wanted to explore git, and I created the cake account to "own" the "server/...
Seamus's user avatar
  • 3,087
0 votes
0 answers
24 views

In `find -exec`, using back quotes (backticks) with `stat` [duplicate]

I would like find to execute a different command depending on what the stats of a file are. If I run the command find . -name "*" -exec echo {} \+ then I get the list of files in the ...
Alex's user avatar
  • 1,175
-1 votes
1 answer
122 views

Bash - cannot stat the last file created in a for...do loop

In a bash script (on Ubuntu 22 if it matters) I have a function which, executed from within a for...do loop, is given a filename to execute some SQLplus <query_name>.sql and store the results in ...
Jock Coats's user avatar
0 votes
0 answers
103 views

Properly escape a string variable that contains special characters to be used in a shell script?

I feel dumb for asking such a simple question but Im absolutely stuck on this one. I've search everywhere, tried several methods to escape or properly quote this variable, but no matter what when I ...
ProfessionalAmateur's user avatar
0 votes
0 answers
38 views

How do I get the number of hardlinks of a folder?

I am on Mac. However, I use gstat (GNU stat) so my understanding is that behavior should match linux. I cd to a folder. Then I use gstat --format=%h .. The output is 65. Next, I use gfind . -maxdepth ...
Matt Groth's user avatar
3 votes
4 answers
394 views

Apply arithmetic into piped command

So far I have this: sudo find /path/to/dir -type f | xargs -d "\n" sudo stat -c "%Y %n" | {arithmetic to check if %Y is between 1685518962 and 1685624474??} | {show ...
MonkeyZeus's user avatar
1 vote
2 answers
126 views

how to list all files in a given period according their duration(not moment) of access

under linux, how to list all files in a given directory and its subdirs, in a given period, say last 10days, according their duration of access, ideally the result ought to be sorted by access ...
user2718593's user avatar
0 votes
1 answer
344 views

How to get the most trusted and accurate linux distro stats?

I need the Linux distros usage statistics. I need this data to make a more informed decision for our future technology choices. However, I can't find the data. It seems that DistroWatch is a good ...
Saeed Neamati's user avatar
6 votes
2 answers
879 views

Why does wc and stat produce different results for /proc/[pid]/cmdline?

I am trying to understand why wc and stat report different things for /proc/[pid]/cmdline. wc says my shell's cmdline file is 6 bytes in size: $ wc --bytes /proc/$$/cmdline 6 /proc/10425/cmdline stat ...
Shane Bishop's user avatar
1 vote
2 answers
385 views

A script to show the age of a linux installation in days

I want to create a command that is called Age which calls this script: From=$(stat / | grep "Birth" | sed 's/Birth: //g' | cut -b 2-11) echo $From Now=$(date) echo $Now However, I'm stuck ...
Saeed Neamati's user avatar
8 votes
1 answer
626 views

Deleting a hard link's tail file changes the change time of the head or vice versa. Why?

Note: Question although says vice versa but it really does not have any meaning since both of them point to the same inode and its not possible to say which is head and which is tail. Say I have a ...
Himanshuman's user avatar
1 vote
1 answer
400 views

Unable to figure the permissions required by lstat

I am running into this weird permission issue on Debian 10, with lstat call on XFS filesystem. I have been referring to this link to understand how extended ACLs will work The man page says that ...
viral_mutant's user avatar
0 votes
1 answer
330 views

How can I obtain the time stamp from a file or directory in touch format?

According to many websites I found online the touch commands' -t argument accepts the time stamp in the following format: [[CC]YY]MMDDhhmm[.ss] Here, CC: The first two digits of the year. YY: The ...
Zoltan King's user avatar
1 vote
1 answer
476 views

How can I efficiently read entries in a directory?

I would like my program to efficiently detect if a file was added to a directory between two invocations. That analysis might block user input (this would be for the fish shell), so I want it to run ...
Narrateur du chaos's user avatar
5 votes
1 answer
1k views

cp overrides my default permissions settings, when copying files with: cp -r --no-preserve=all

My default umask is 077. When I create a directory, it has permissions 700: mkdir AA $ stat -c'%A %n' AA/ drwx------ AA/ now I want to set default permissions recursively to 750: ...
Martin Vegter's user avatar
3 votes
0 answers
474 views

Change file creation timestamp on an exFAT volume from Linux

The question As of today, Unix standards don't support a file "creation time" attribute. However, many filesystems, like ext4, exFAT and NTFS, internally do save a creation time for their ...
Totor's user avatar
  • 20.3k
0 votes
2 answers
818 views

What is the fastest way to fetch last modified TS on a file in bash?

If you have a list of hundreds of thousands of files across an enormous filesystem, what's the fastest way in bash to get the last modified time of all of them? Assuming there's no way to sort them ...
Jun-Dai Bates-Kobashigawa's user avatar
1 vote
0 answers
334 views

ls displays no files even though folder contains files

This question is actually derived from a problem I have with a python library which deletes a file tree and then recreates the content, but on attempt of execution of a file inside the directory, the ...
PrivateOmega's user avatar
0 votes
4 answers
784 views

How to get date string from stat command?

I have this to get the timestamp of a directory: stat -c %Y directory_name What can I pipe this to, to get the date formatted like this? 20220201
CJ7's user avatar
  • 839
0 votes
1 answer
300 views

"stat /etc" size mismatch: 24 blocks, size 8192 instead of 12288

My stat /etc command shows that the number of blocks is 24. I understand that a block here means 512 bytes. So the total size is 24 × 512 which makes it 12288 bytes. But it shows 8192 bytes instead, ...
TheRoguePrince's user avatar
0 votes
1 answer
29 views

Changing rights and owner in one command to safe resources

I have a backup script with the following function: function change_rights() { chown -R ${OWNER}:${GROUP} ${DIR} find ${DIR} -type f -exec chmod 0640 {} \; find ${DIR} -type d -exec chmod ...
manifestor's user avatar
  • 2,483
1 vote
1 answer
2k views

Convert date format of a stat command output

With the command stat * --format='%A %h %U %G %s %z %n' I get: -rwxrwxrwx 1 myuser mygroup 131072 2021-11-12 14:52:23.495595927 +0100 myfile Is it possible to have a stat output like the following? ...
CarLaTeX's user avatar
  • 329
0 votes
2 answers
66 views

Can I post-format column tab sizes so that spacing is at lowest common denominator in Linux?

I can use stat to create an ls output that shows both formats of permission information which can be handy: stat --printf="%A\t%a\t%h\t%U\t%G\t%s\t%.19y\t%n\n" . .* drwxr-xr-x 755 ...
YorSubs's user avatar
  • 641
0 votes
0 answers
218 views

can't stat file more than once?

So I've got a bizarre error that occurs when I use ffmpeg.ffprobe on an MP4 file that is hosted my NAS. When I login to a shell and switch to any directory on my network storage that contains a MP4 ...
rothloup's user avatar
  • 111
9 votes
1 answer
721 views

On what UNIX-like system / filesystem is the st_blocks field returned by stat() not a number of 512-byte units?

I always assumed the st_blocks field returned by stat()/lstat()... system calls and which du uses to get the disk usage of files was expressed in 512 bytes units. Checking the POSIX specification, I ...
Stéphane Chazelas's user avatar
0 votes
1 answer
87 views

How to monitor calls to stat?

I'd like to monitor calls to stat on any file within a directory. I know inotifywait can listen for file creation etc. but I don't know anything that can listen for stat. This is on Amazon Linux 2. ...
Johnny's user avatar
  • 101
2 votes
1 answer
46 views

Ensuring no files were deleted from directory at a certain time

I accidentally started an rm -rf on a large directory that I was working in. The directory contains, among other things, a data directory containing a number of subdirectories that each contain ...
Angus L'Herrou's user avatar
1 vote
1 answer
179 views

Can stat show if file is hidden?

I'm using stat like this: stat -f "%Sp %p %l %Su %u %Sg %g %z %a %N %Y" /* I need also to tell if the file is hidden or not (MacOS). The . notation is not enough. MacOS hides more files. ...
PerfectGamesOnline.com's user avatar
0 votes
0 answers
35 views

Directory changed into a regular file upon a UI drag/drop, now how do I change it back?

I'm on Ubuntu 16.04LTS with the latest Linux kernel 4.4.0-206-generic from Canonical (which could be bugged), and I've never seen anything like this before! Somehow, simply dragging and dropping a ...
Chris Parker's user avatar
0 votes
1 answer
1k views

`noatime` mount option's effect on `stat` access time

I have mounted ext4 partition in Ubuntu 20.04 with noatime mount option in my /etc/fstab From stat: Access time doesn't change when the file is opened on the editor or modified and saved, while ...
Porcupine's user avatar
  • 2,056
0 votes
1 answer
45 views

Ipad 4 mini Date says 12,31,1969

I used terminal code stat in my iPad, and it came back as show below. Why does it say that date, how can I fix this? And is there other things I should check? GFY iPad 2 $ stat 0 9870584235507384862 ...
B W's user avatar
  • 1
1 vote
1 answer
2k views

Birth time after Modify time in stat command

I have a folder with a Birth time later than its Modify time: File: Pictures Size: 4096 Blocks: 8 IO Block: 4096 directory Device: 804h/2052d Inode: 31724953 Links: 4 Access: ...
alexis's user avatar
  • 417
1 vote
1 answer
593 views

How do I read the terse outout of stat?

There are no clues given about how to interpret the results of running the stat command with terse output. [root@kvm devicemapper]# stat -t data data 107374182400 3887728 8180 0 0 fd01 559688 1 0 0 ...
activedecay's user avatar
2 votes
1 answer
2k views

Why is the type of stat.st_size not unsigned int?

I was trying to rely on the stat(2) system-call to determine the size of a file in order to allocate an appropriate buffer for it. More specifically I was using the stat.st_size of the structure that ...
shaqed's user avatar
  • 881
0 votes
1 answer
251 views

Linux find command - find files based on inode and device?

I want to find the files with a given inode number. Using find with -inum is not entirely helpfull as its listing files with the inode number from every file system/device. How to confine this search ...
samshers's user avatar
  • 688
0 votes
1 answer
2k 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 ...
fa7eme's user avatar
  • 43
3 votes
1 answer
901 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 ...
genericuser99's user avatar
0 votes
0 answers
249 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 ...
John D.'s user avatar
  • 101
0 votes
1 answer
99 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 ...
user4434's user avatar
1 vote
2 answers
908 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 ...
Luka's user avatar
  • 11
0 votes
1 answer
492 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 ...
Fredrik's user avatar
  • 11
0 votes
1 answer
54 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 ...
Fredrik's user avatar
  • 11
2 votes
0 answers
745 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 (...
Paulo Tomé's user avatar
  • 3,792
7 votes
1 answer
6k 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 ...
stas's user avatar
  • 73
3 votes
2 answers
2k 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 ...
thb's user avatar
  • 1,145