ls

Quick ls command

旧街凉风 提交于 2021-02-05 20:12:21
问题 I've got to get a directory listing that contains about 2 million files, but when I do an ls command on it nothing comes back. I've waited 3 hours. I've tried ls | tee directory.txt , but that seems to hang forever. I assume the server is doing a lot of inode sorting. Is there any way to speed up the ls command to just get a directory listing of filenames? I don't care about size, dates, permission or the like at this time. 回答1: ls -U will do the ls without sorting. 回答2: Try using: find .

lstat: can't access files in another directory

你说的曾经没有我的故事 提交于 2021-02-05 08:09:31
问题 I'm trying to write ls-alike program that produces output like ls -l with permissions, owners, time and name of the file. It works good if I pass . (or nothing), so it works with the current directory. But if I pass any other directory in or out of the current one, perror says it "can't access" the files. Please, help me figure out what prevents lstat from accessing files in another dirs. I use gcc and a text editor, no IDE, started learning to use gdb (tried to debug but didn't find

read raw input lines and output single array

允我心安 提交于 2021-01-28 23:59:13
问题 I have a directory with files in it. I would like to create an array from that list of files. I thought it would be pretty easy, like: ls mydir | jq -R '[.]' [ "file1" ] [ "file2" ] [ "file3" ] The only thing I could figure out is this: ls mydir | jq -sR '[split("\n")[]|select(.|length>0)]' [ "file1", "file2", "file3" ] Is there a better way? 回答1: You'd have to be extra careful in dealing with Unix filenames in general. They can contain almost any character in a filename, including whitespace

read raw input lines and output single array

China☆狼群 提交于 2021-01-28 23:46:46
问题 I have a directory with files in it. I would like to create an array from that list of files. I thought it would be pretty easy, like: ls mydir | jq -R '[.]' [ "file1" ] [ "file2" ] [ "file3" ] The only thing I could figure out is this: ls mydir | jq -sR '[split("\n")[]|select(.|length>0)]' [ "file1", "file2", "file3" ] Is there a better way? 回答1: You'd have to be extra careful in dealing with Unix filenames in general. They can contain almost any character in a filename, including whitespace

read raw input lines and output single array

此生再无相见时 提交于 2021-01-28 22:40:05
问题 I have a directory with files in it. I would like to create an array from that list of files. I thought it would be pretty easy, like: ls mydir | jq -R '[.]' [ "file1" ] [ "file2" ] [ "file3" ] The only thing I could figure out is this: ls mydir | jq -sR '[split("\n")[]|select(.|length>0)]' [ "file1", "file2", "file3" ] Is there a better way? 回答1: You'd have to be extra careful in dealing with Unix filenames in general. They can contain almost any character in a filename, including whitespace

Unix ls command option to print file author

寵の児 提交于 2020-08-12 03:59:06
问题 Can anyone tell me which ls option to use to print the author or owner of a file? I have searched for over 2 hours and the only thing I have found is hyphen hyphen author which doesn’t work. I tried Unix.com, unixtutorial.com, Ubuntu.com and about a dozen other sites. I used Google, Yahoo, Bing, DuckDuckGo. I’m about ready to chuck it all and give up. 回答1: To get the author, you combine --author with -l (it doesn't work without it). Keep in mind that, in most UNIXes that support ls --author ,

bash: /bin/ls: Argument list too long

走远了吗. 提交于 2020-04-10 07:43:16
问题 I need to make a list of a large number of files (40,000 files) like below: ERR001268_1_100.fastq ERR001268_2_156.fastq ERR001753_2_78.fastq ERR001268_1_101.fastq ERR001268_2_157.fastq ERR001753_2_79.fastq ERR001268_1_102.fastq ERR001268_2_158.fastq ERR001753_2_7.fastq ERR001268_1_103.fastq ERR001268_2_159.fastq ERR001753_2_80.fastq my command is: ls ERR*_1_*.fastq |sed 's/\.fastq//g'|sort -n > masterlist However error is: bash: /bin/ls: Argument list too long However can I solve this problem