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
-1
votes
1 answer

How to access errno after using syscall?

I'm using syscall stat, it returns 0/-1. When -1 is returned it means, error occurred and errno is set as it should be (source: man 2 stat). But I want to access errno and print it, how to do that?
-1
votes
1 answer

stat comand - compute difference of two timestamps

I would like to compute the difference of two timestamps using a bash script: one which is the output of stat command and another one is defined as a string. The format of file timestamp is as follows: 2018-06-17 20:02:59
Adib Rastegarnia
  • 494
  • 1
  • 7
  • 21
-1
votes
1 answer

Program wchich reads its own size from st_size

Using stat() function and main function arguments I have to write a program which reads and prints its own size from st_size. What I've already tried: #include #include int main( const char * szFileName ) { struct…
Sz3jdii
  • 507
  • 8
  • 23
-1
votes
1 answer

How do I find the Total number of disk blocks taken by the current directory (C UNIX)?

so I've almost finished my assignment where I basically recreated the UNIX ls -l command, but the only thing missing is the 'total #' that is shown at the beginning of the ls -l command as shown below. total 68 From my understanding this is the…
noel880
  • 35
  • 6
-1
votes
1 answer

stat() is returning that existing files don't exist (C)

I'm having a really weird issue that I can't seem to solve. I am trying to stat the files in a directory in my C program but valid files are returning -1 (the file doesn't exist). The thing is, the files are valid and do have some data in them.…
Husk Rekoms
  • 483
  • 12
  • 22
-1
votes
1 answer

find files by extension containing certain text and display the file path and modified date

I need to find all .txt files containing "abc" in their content and display the filepath and modified date: Maybe something like: > find /folder -iname '*.txt' -print0 | xargs -0 grep -i -n -l "abc" | xargs echo Expected…
luistar15
  • 163
  • 1
  • 9
-1
votes
1 answer

Struct stat and stat function failure

So, I'm trying to make a sort of ls function. Here's my code to the description of each file struct stat fileStat; struct dirent **files; num_entries = scandir(filename, &files, file_select, alphasort); stat(files[i-1]->d_name,fileStat); for some…
Jose A
  • 31
  • 6
-1
votes
1 answer

C: Why I am getting a Segmentation Fault when trying to create a new folder/directory?

I am trying to create a new folder using two command line arguments, one being the destination folder and the other the source, but I am getting a "Segmentation fault (core dumped)" error. Could you please help me figure out what is causing this…
01eg
  • 1
-1
votes
1 answer

Data aggregation by week or by 3 days

Here is an example of my data: Date Prec aggregated by week (output) 1/1/1950 3.11E+00 4.08E+00 1/2/1950 3.25E+00 9.64E+00 1/3/1950 4.81E+00 1.15E+01 1/4/1950 7.07E+00 …
Wis786
  • 53
  • 8
-1
votes
1 answer

obtain owner name and group from stat function c++

Good day every one. I use function stat on windows to get information from file, but how i can get name from st_uid and st_gid (it's a short). I use visual stydio 2015
-1
votes
1 answer

what happens if i interpret the stat() attributes when stat() for directory path fails?

i have a requirement where i need to check a given directory exists or not. i am doing like this structure stat buf; stat(dir_path,buf); if( S_ISDIR(buf.st_mode) ) cout << " its a directory " << endl; else cout << " its not a directory " <<…
-1
votes
1 answer

How to create quintile of variable in R

Is it possible to bin a variable in to quintile (1/5th) using R. And select only the variables that fall in the 5th bin. As of now I am using the closest option which is quartile (.75) as there is not a function to do quintile. Any suggestions…
I Phoenix
  • 49
  • 1
  • 1
  • 9
-1
votes
1 answer

My ls -R doesn't work

Having issues with my ls -R implemented in C. When I run the program with command ./myls -R nothing displays, all blank:(Help needed. int print_Recursive(char *dirname) { char fbuf [256]; DIR *dir; struct dirent *dirp; struct stat…
Anastasia Netz
  • 173
  • 2
  • 12
-1
votes
2 answers

Stat Structure Segmentation Fault

struct stat { dev_t st_dev; /* ID of device containing file */ ino_t st_ino; /* inode number */ mode_t st_mode; /* protection */ nlink_t st_nlink; /* number of hard links */ uid_t st_uid; /* user ID of owner…
j1nrg
  • 69
  • 7
-1
votes
1 answer

solaris10 stat command not found but works in perl

I was reading a page about the performance of delete operation on thousands of files and it mentions the command below perl -e 'for(<*>){((stat)[9]<(unlink))}' Could anyone explain me why I have a 'command not found' while calling command 'stat'…