Questions tagged [stat]

The stat(2) system call on POSIX systems. For statistics, use the statistics instead.

The stat(2) system call is used to retrieve information about a named file (or directory).

Links:

For statistics, use the tag instead.

829 questions
110
votes
6 answers

How to display modified date time with 'find' command?

With a find command, I can display directories names with multiple levels. The following command display all directories under /var path with a depth of 2: find /var -maxdepth 2 -type d; The result…
Purres
  • 1,271
  • 2
  • 11
  • 12
104
votes
15 answers

How to get summary statistics by group

I'm trying to get multiple summary statistics in R/S-PLUS grouped by categorical column in one shot. I found couple of functions, but all of them do one statistic per call, like aggregate(). data <- c(62, 60, 63, 59, 63, 67, 71, 64, 65, 66, 68, 66,…
user1289220
  • 1,041
  • 2
  • 8
  • 3
83
votes
3 answers

From stat().st_mtime to datetime?

What is the most idiomatic/efficient way to convert from a modification time retrieved from stat() call to a datetime object? I came up with the following (python3): from datetime import datetime, timedelta, timezone from pathlib import Path path =…
Travis Griggs
  • 21,522
  • 19
  • 91
  • 167
67
votes
5 answers

Method to extract stat_smooth line fit

Is there a way to extract the values of the fitted line returned from stat_smooth? The code I am using looks like this: p <- ggplot(df1, aes(x=Days, y= Qty,group=Category,color=Category)) p <- p + stat_smooth(method=glm, fullrange=TRUE)+…
MikeTP
  • 7,716
  • 16
  • 44
  • 57
42
votes
5 answers

R "stats" citation for a scientific paper

I analyzed my data using R package ‘stats’ (version 2.15.3). A reviewer asked me the right citation of this package and not only the common R Core Team (2012). R: A language and environment for statistical computing. R Foundation for Statistical…
Gianni Spear
  • 7,033
  • 22
  • 82
  • 131
41
votes
3 answers

Difference between lstat fstat and stat in C

Im writing a school assignment in C to search through a file system for directories, regular files and symlinks. For now i use lstat to get information about items. So whats the difference between lstat fstat and stat system calls?
uzr
  • 1,210
  • 1
  • 13
  • 26
28
votes
2 answers

understanding and decoding the file mode value from stat function output

I have been trying to understand what exactly is happening in the below mentioned code. But i am not able to understand it. $mode = (stat($filename))[2]; printf "Permissions are %04o\n", $mode & 07777; Lets say my $mode value is 33188 $mode &…
chidori
  • 1,052
  • 3
  • 12
  • 25
20
votes
2 answers

filesize(): stat failed for specific path - php

i am coding a simple doc managing script and need to get the file size and file type /file or folder/ in a table. somehow it doesn't work into the mention directory. please help if possible:
Ivan M
  • 209
  • 1
  • 2
  • 9
20
votes
4 answers

Implementing the ls -al command in C

As a part of an assignment from one of my classes, I have to write a program in C to duplicate the results of the ls -al command. I have read up on the necessary materials but I am still not getting the right output. Here is my code so far, its only…
ankur3000
  • 203
  • 1
  • 2
  • 5
20
votes
3 answers

Printing file permissions like 'ls -l' using stat(2) in C

I am trying to write a small C program that emulates the unix command ls -l. To do so, I am using the stat(2) syscall and have ran into a small hiccup writing the permissions. I have a mode_t variable which holds the file permissions from…
cheezone
  • 345
  • 1
  • 2
  • 9
19
votes
2 answers

Having trouble understanding how fs.stat() works

I'm trying to write a function that tells me is a certain path is a directory. var fs = require('fs'); console.log("+++++++++++++++++++++++++++++++++++++++"); fs.statSync(pathname, function(err, stats) { …
Asher Saban
  • 4,673
  • 13
  • 47
  • 60
18
votes
1 answer

How to figure out if a file is a link?

I have the below code only a part of it is shown here and I am checking if a the type of file. struct stat *buf /* just to show the type buf is*/ switch (buf.st_mode & S_IFMT) { case S_IFBLK: printf(" block device\n"); break; …
Eternal Learner
  • 3,800
  • 13
  • 48
  • 78
18
votes
2 answers

Git log --stat summary of branch

I would like to show how many changes (insertions+deletions) I made on a feature branch. Is there a way to get a summary of the git log --stat output for the changes between 2 commits (branch root / tip). Thanks.
opatut
  • 6,708
  • 5
  • 32
  • 37
18
votes
3 answers

Using stat to check if a file is executable in C

For homework I have to write a C program and one of the things it has to do is check to see a file exists and if it is executable by the owner. Using (stat(path[j], &sb) >= 0 I'm able to see if the file indicated by path[j] exists. I've looked…
Joseph Kahn
  • 396
  • 1
  • 3
  • 16
15
votes
5 answers

Why is stat::st_size 0 for devices but at the same time lseek defines the device size correctly?

I noticed that when I query the size of a device using open + lseek, everything is OK, but when I stat the device, I get zero instead of the real device size. The device is clean without any file system and the first bytes of device start with some…
1
2 3
55 56