ls

How to read first n-th files from directory (pleaso NOT a “head -n solution”)?

本小妞迷上赌 提交于 2019-12-24 12:30:43
问题 I have a directory with more then 60000 files. How to get only N of them without using a find | head -n or ls | head -n solutions, since find and ls to read this list of files takes too much time. Are there any configs for ls and find or are there any other programs, which can help to safe the time? 回答1: For what it worth: # Create 60000 files sh$ for i in {0..100}; do for j in {0..600}; do touch $(printf "%05d" $(($i+$j*100))); done; done On Linux Debian Wheezy x86_64 w/ext4 file system: sh$

Linux “ls -al” like program in C

半腔热情 提交于 2019-12-24 04:13:06
问题 I have for homework to write a C program, which is acting like the Linux "ls -al" command. I know that there are a lot of example programs over the internet, which are doing the thing that I need, but I have a specific problem, to which I can't find a solution. I also want to mention, that I am new to C programming. Here is my code : #include <stdio.h> #include <stdlib.h> #include <dirent.h> #include <errno.h> #include <string.h> #include <sys/types.h> #include <sys/stat.h> #include <unistd.h

R List functions in file

空扰寡人 提交于 2019-12-24 01:44:31
问题 How do I list all functions of a certain R file doing something like list = list.all.functions(file.name, alphabetical = TRUE, ...) where list is a string vector containing the names of the functions in file.name ? The solution of How to list all the functions and their arguments in an R file? gives no output for me (since I am not interested in arguments I opened a new question). EDIT File allometry.R starts with #==============================================================================

C: <sys/stat.h> functions S_ISLNK, S_ISDIR and S_ISREG behaving oddly?

对着背影说爱祢 提交于 2019-12-24 00:53:25
问题 The code this is taken from compiles fine. It prints file names in a directory with the option of a letter in front of it: either a d , f , l , or o depending on their file type ( o for other). However, I tested it on the directory /etc/network which has a symbolic file called run and it appeared as d ? I've tried re-arranging the order of the if-statements too, but that gives an unsatisfactory output too. Am I using it incorrectly? while ((ent = readdir (dp)) != NULL) { lstat(ent->d_name,

How to sort SVN LS -R output by date

点点圈 提交于 2019-12-23 15:32:52
问题 I want to list all the files in my svn, sorted by date of last commit. svn ls -Rv lists all the files, but it doesn't accept a -t switch. Does anyone know how to do this? (I have seen an answer to a similar question for svn status , but it wasn't obvious to me how to change this to work with svn ls .) STILL UNANSWERED: It would also be helpful to be able to sort the files by date added to SVN. 回答1: On my Windoz box the below does the job svn ls -Rv | sort For Unix you will, most likely, have

GNU ls from Coreutils missing OS X ACL implementation

别来无恙 提交于 2019-12-23 02:41:48
问题 I'm using brew to retrieve and install common GNU versions of terminal commands and utils with brew install coreutils . Then in my .bash_profile I'm including their PATH with if [ -d $(brew --prefix coreutils)/libexec/gnubin ]; then PATH="$(brew --prefix coreutils)/libexec/gnubin:$PATH" fi so far so good, I can use use the GNU version of coreutils. The problem comes from ls . Apple implement ACL that is not implemented on GNU ls . I discovered this by banging my head many times and not

List all files not starting with a number

≯℡__Kan透↙ 提交于 2019-12-21 12:13:07
问题 I want to examine the all the key files present in my /proc . But /proc has innumerable directories corresponding to the running processes. I don't want these directories to be listed. All these directories' names contain only numbers. As I am poor in regular expressions, can anyone tell me whats the regex that I need to send to ls to make it NOT to search files/directories which have numbers in their name? UPDATE : Thanks to all the replies! But I would love to have a ls alone solution

how to `git ls-files` for just one directory level.

浪子不回头ぞ 提交于 2019-12-21 03:33:27
问题 I'm using msysgit (1.7.9), and I'm looking for the right invocation of the git ls-files command to show just the (tracked) files and directories at the current level, either from the index, or the current working directory if that's easier. Essentially it would give a directory listing similar that that you would see on Github. Coming from Windows, I'm not too familiar with the right way of doing the globbing(?). 回答1: I think you want git ls-tree HEAD sed'd to taste. The second word of ls

Implementing the ls -al command in C

£可爱£侵袭症+ 提交于 2019-12-20 17:40:57
问题 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 supposed to print out the file size and the file name, but the file sizes its printing are not correct. Code: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <dirent.h> int main(int

Implementing the ls -al command in C

自闭症网瘾萝莉.ら 提交于 2019-12-20 17:40:40
问题 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 supposed to print out the file size and the file name, but the file sizes its printing are not correct. Code: #include <sys/types.h> #include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <stdlib.h> #include <dirent.h> int main(int