ls

How do I turn OFF colors for ls output in Terminal on OSX

回眸只為那壹抹淺笑 提交于 2020-01-05 03:57:11
问题 my ls output colors all directories differently from files, regardless whether I type ls or /bin/ls . I don't have any LS_COLOR stuff set in .bashrc or related files that I can find. How do I turn off these colors? (I am quite happy with just ls -F ) Thanks! 回答1: As noted in comment, OSX ls pays attention to CLICOLOR . The ls manual page is the place to look. It appears to be the same program as in FreeBSD, which uses the terminal database (in contrast to GNU ls). Likewise, note that the

Calling 'ls' with execv

做~自己de王妃 提交于 2020-01-04 04:08:25
问题 I am new to system calls and C programming and am working on my university assignment. I want to call the 'ls' command and have it print the directory. What I have: (I have added comments in so you can see what I see coming through each variable. int execute( command* cmd ){ char full_path[50]; find_fullP(full_path, p_cmd); //find_fullP successfully updates full_path to /bin/ls char* args[p_cmd->argc]; args[0] = p_cmd->name; int i; for(i = 1; i < p_cmd->argc; i++){ args[i] = p_cmd->argv[i]; }

How to sort output of “s3cmd ls”

十年热恋 提交于 2020-01-02 01:21:31
问题 Amazon "s3cmd ls" takes like this output: 2010-02-20 21:01 1458414588 s3://file1.tgz.00<br> 2010-02-20 21:10 1458414527 s3://file1.tgz.01<br> 2010-02-20 22:01 1458414588 s3://file2.tgz.00<br> 2010-02-20 23:10 1458414527 s3://file2.tgz.01<br> 2010-02-20 23:20 1458414588 s3://file2.tgz.02<br> <br> How to select all files of archive, ending at 00 ... XX, with the latest date of fileset ? Date and time is not sorted. Bash, regexp ? Thanx! 回答1: DATE=$(s3cmd ls | sort -n | tail -n 1 | awk '{print

How to use ls to list out files that end in numbers

风格不统一 提交于 2020-01-01 19:53:33
问题 I'm not sure if I'm using regular expressions in bash correctly. I'm on a Centos system using bash shell. In our log directory, there are log files with digits appended to them, i.e. stream.log stream.log.1 stream.log.2 ... stream.log.nnn Unfortunately there are also log files with the new naming convention, stream.log.2014-02-14 stream.log.2014-02-13 I need to get files with the old log file naming format. I found something that works but I'm wondering if there's another more elegant way to

Find count of files matching a pattern in a directory in linux

大憨熊 提交于 2019-12-31 13:15:15
问题 I am new to linux. I have a directory in linux with approx 250,000 files I need to find count of number of files matching a pattern. I tried using following command : ls -1 20061101-20131101_kh5x7tte9n_2010_* | wc -l I got the following error message: -bash: /bin/ls: Argument list too long 0 Please help. Thanks in advance 回答1: It might be better to use find for this: find . -name "pattern_*" -printf '.' | wc -l In your specific case: find . -maxdepth 1 -name "20061101-20131101_kh5x7tte9n_2010

Linux delete file with size 0 [duplicate]

孤者浪人 提交于 2019-12-29 02:22:29
问题 This question already has answers here : How to delete many 0 byte files in linux? (10 answers) Closed 3 years ago . How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script. l filename.file | grep 5th-tab | not eq 0 | rm Something like this? 回答1: This will delete all the files in a directory (and below) that are size zero. find /tmp -size 0 -print0 |xargs -0 rm -- If you just want a particular file; if [ ! -s /tmp/foo ] ; then rm

Linux delete file with size 0 [duplicate]

倖福魔咒の 提交于 2019-12-29 02:22:08
问题 This question already has answers here : How to delete many 0 byte files in linux? (10 answers) Closed 3 years ago . How do I delete a certain file in linux if its size is 0. I want to execute this in an crontab without any extra script. l filename.file | grep 5th-tab | not eq 0 | rm Something like this? 回答1: This will delete all the files in a directory (and below) that are size zero. find /tmp -size 0 -print0 |xargs -0 rm -- If you just want a particular file; if [ ! -s /tmp/foo ] ; then rm

How do I assign ls to an array in Linux Bash?

二次信任 提交于 2019-12-28 04:54:11
问题 array=${ls -d */} echo ${array[@]} I have three directories: ww ee qq . I want them in an array and then print the array. 回答1: It would be this array=($(ls -d */)) EDIT: See Gordon Davisson's solution for a more general answer (i.e. if your filenames contain special characters). This answer is merely a syntax correction. 回答2: Whenever possible, you should avoid parsing the output of ls (see Greg's wiki on the subject). Basically, the output of ls will be ambiguous if there are funny

Size() vs ls -la vs du -h which one is correct size?

偶尔善良 提交于 2019-12-28 04:31:06
问题 I was compiling a custom kernel, and I wanted to test the size of the image file. These are the results: ls -la | grep vmlinux -rwxr-xr-x 1 root root 8167158 May 21 12:14 vmlinux du -h vmlinux 3.8M vmlinux size vmlinux text data bss dec hex filename 2221248 676148 544768 3442164 3485f4 vmlinux Since all of them show different sizes, which one is closest to the actual image size? Why are they different? 回答1: They are all correct, they just show different sizes. ls shows size of the file (when

Changing color of my directories listed by my directory

走远了吗. 提交于 2019-12-25 02:36:21
问题 I tried changing the color/attributes of directory listings of ls command by editing .dircolors file but it doesn't work. Before that it is worth mentioning that i have added the below changes in the bash.bashrc file. # enable color support of ls and also add handy aliases if [ "$TERM" != "dumb" ]; then [ -e "$HOME/.dircolors" ] && DIR_COLORS="$HOME/.dircolors" [ -e "$DIR_COLORS" ] || DIR_COLORS="" eval "`dircolors -b $DIR_COLORS`" alias ls='ls --color=auto' #alias dir='ls --color=auto -