Tag Info

Hot answers tagged

12

Accepting command options arguments after file operands is not standard and isn't often supported in non-GNU system, you need: ls -d1 sel* A note that -d1 isn't depth 1 like you think. -d tell ls list directories themselves, not their content -1 tell ls list one entry per line


8

You can reenable aliases as described at http://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo the short version is to add and alias for sudo as alias sudo='sudo ' to get it to check the rest of the command for aliases. Otherwise, the sudo is check to see if it's an alias, it is not, so the rest of the alias checking ends. If sudo ...


5

Those files are special files called devices. They don't have a size parameter, but two number called major and minor number. Major is somehow related to type of device (terminal, disks, network interface, filesystems). Minor is related instance number. I use the word "related", you simply do not count, different disk might have different major number. ...


3

I should think: ls ./* | cut -d '.' -f 1,2,3 | sort -u will get you there, this essentially lists the contents of the directory, then cuts off everything after the third '.' and then sorts the lines and removes duplicates. The end result would be a list of 'abc.sh.ID'. If you want you loop through this new list and do an 'ls [line]*' to get the ...


3

If you're going to just cat a newest file in one command you don't really need -l option. On Linux and Cygwin you can use -1 option and make parsing much easier: $ cat "$(ls -1rt | tail -n1)" -1 should be very portable, it's specified in POSIX. Also keep in mind that parsing ls output has its drawbacks. EDIT: As correctly noted in a comment by ...


2

This will get you the count of files in each subdirectory of the current directory, dealing with any strange file names (with gnu find). find . -maxdepth 2 -mindepth 2 -type f -printf "%h\0" | uniq -zc | tr '\0' '\n'


2

My solution might be a little heavy but well, who knows. The problem is that, in order to do that, you would need to count files... which is usually done with: $ ls | wc -l Now, because the content is written to a pipe, and not to stdout, this will take a little less time to complete (writing to a terminal takes a little bit of time, which can become ...


2

With ksh93: printf '%s\n' {12}(?) for (non-hidden) files whose name are made of 12 characters. Or if you prefer regular expressions: printf '%s\n' ~(E)^.{12}$


2

With zsh you could use a glob like ?(#cN) (here the c flag requires the previous ? to match exactly N times): setopt extendedglob print -rl -- ?(#c12) if you prefer ls: ls -d -- ?(#c12) You can also add qualifiers, e.g. search recursively for regular files with fixed name length: print -rl -- **/?(#c12)(.)


1

Assuming your file names don't contain newline characters and your grep supports the -o option: find [[:upper:]] -type f | grep -Eo '^./[0-9]{3}' | sort | uniq -c


1

--hide=PATTERN in the fine manual looks promising, e.g. set a shell alias for ls that includes appropriate things to hide.


1

This method doesn't score highly in terms of correctness but should work in most cases: cat "$(ls -1t | head -n1)"


1

Assuming that you have no spaces in your directory names: for dir in $(find . -type d); do echo "${dir}: $(find ${dir} -maxdepth 1 -type f | wc -l)" done


1

printf '%s\n' * as a shell command will list the non-hidden files in the current directory, one per line. If there's no non-hidden file, it will display * alone except in those shells where that issue has been fixed (csh, tcsh, fish, zsh, bash -O failglob). echo * Will list the non-hidden files separated by space characters except (depending on the ...


1

If you just want a list of directory contents: find . -maxdepth 1 or for any other dir: find <dir> -maxdepth 1


1

Using the same ls -CFUd as muru but in zsh, you could try with: setopt nullglob ls --color -CFUd -- *(/) *(*) *(@) *(p) *(=) *(^/*@p=) where (...) are glob-qualifiers matching directories, executables, symlinks, pipes, sockets and respectively everything else.


1

If dirty hacks are welcomed, the following might come close: ls -C --color -F -1 | rev | sort | rev Essentially: rev to get the last character first then sort, which will now use the last character first then rev again to get back the original line This, unfortunately, has single-column output. You can apply column to it to get multi-column output, ...


1

Presumably the external drive uses a filesystem such as a FAT variant which doesn't store permissions, and was mounted with all permissions allowed to everybody. The tool you used to copy files retained the original permissions. The garish color alerts you that the files are world-writable. In the output of ls -l, the rwx permissions are grouped in three ...



Only top voted, non community-wiki answers of a minimum length are eligible