Tag Info

Hot answers tagged

7

ls -F will: Write a ( '/' ) immediately after each pathname that is a directory, an ( '*' ) after each that is executable, a ( '|' ) after each that is a FIFO, and an at-sign ( '@' ) after each that is a symbolic link. GNU ls includes additional signals: ... ‘=’ for sockets, ‘>’ for doors = is also present in the major BSDs (FreeBSD, OpenBSD, ...


7

This output: $ ls -al /usr/lib/*valgrind* drwxr-xr-x 2 root root 4096 Sep 30 00:01 . drwxr-xr-x 24 root root 12288 Sep 30 00:00 .. -rwxr-xr-x 1 root root 1816444 Jun 6 2014 cachegrind-x86-linux indicates that there is a directory named /usr/lib/*valgrind* (most likely just /usr/lib/valgrind) which you're ...


7

For the stated question you can use find: find . -mindepth 1 ! -type l will list all files and directories in the current directory or any subdirectories that are not symlinks. mindepth 1 is just to skip the . current-directory entry. The meat of it is the combination of -type l, which means "is a symbolic link", and !, which means negate the following ...


6

From version 2.12 onwards, the -r option for GNU grep doesn’t dereference symbolic links unless you specify them by hand: -r, --recursive Read all files under each directory, recursively, following symbolic links only if they are on the command line. This is equivalent to the -d recurse option. -R, --dereference-recursive ...


6

You may want to check this: ls -l --time=atime atime — updated when file is read mtime — updated when the file changes. ctime — updated when the file or owner or permissions changes. Have fun! :)


5

Edit in response to updated question Since you only care about links, directories and regular files, and don't need to deal with the other filetypes that ls can identify (FIFOs, sockets etc), you could do something like stat. For the examples below, I have created the following test environment: $ ls -l total 4.0K -rw-r--r-- 1 terdon terdon 0 Jun 30 ...


5

Try: ls -lu If you want sorted result by access time: ls -ltu From man ls: -u with -lt: sort by, and show, access time with -l: show access time and sort by name otherwise: sort by access time If you want to get full date time, use --full-time: $ ls -ltu --full-time Or use GNU stat: $ stat -c "%x" -- test.txt 2014-06-30 ...


5

Your folder can have some hidden files (ls doesn't show dot files by default, i.e. files whose name begins with . are hidden). Run: ls -la gamesForAdmin to check if there is any hidden files in it. Updated According to your result ls -la, your directory is not empty, so rmdir can not remove it, rmdir only work with empty directory. To remove it, you ...


5

-t lists the file's modification time, which is the last time the file's content was modified (unless the modification time was explicitly set afterwards). -c lists the file's inode change time, which is the last time the file's metadata was changed (ownership, permissions, etc.) or the file was moved. Most unix systems do not track the creation date of a ...


5

The output of the "ls" command depends on the version of "ls", the options used, the platform used, etc. It appears from your example that you're using it from a typical un*x shell (such as Linux), and probably using a typical modern ls version.. In which case: -rwxrw-r-- 10 root root 2048 Jan 13 07:11 afile.exe ?OOOGGGWWWS 00 UUUUUU GGGGGG ...


3

In zsh, this would be easy thanks to glob qualifiers: grep PATTERN **/*(.) The pattern **/ traverses subdirectories recursively. The glob qualifier . restricts matching to regular files. Without zsh, use find (see Michael Horner's answer). And in this particular case, GNU grep can do what you want (it's exactly what grep -r does) — but only since version ...


3

Based on the output you're showing in your question the directory gamesForAdmin is not empty, so rmdir cannot remove this directory. To remove it you'll need to use rm -fr instead. Try this: sudo rm -rf gamesForAdmin which should fix you right up.


3

You need to use GNU stat command. Example: stat my_file.txt will give you what you are looking for.


2

I assume that your file names don't contain newlines. find /home/setefgge/public_html -type f -ctime -1 -exec ls -nls {} + | sort -k 10 Using + instead of ; to terminate the -exec action makes it faster by batching the invocations of ls. You can sort by piping through the sort command; tell it to start sorting at the 10th field (the first 9 are the ...


2

ls -al is great for checking to see if there are any hidden directories. Barring that rm -rf removes recursively and forces the removal, keep in mind that rm -rf \ will delete everything. Depending on distro this may throw an error, or demo your entire file system. Ubuntu normally doesn't let you do an rm to your root filesystem.


2

You can use find. List all files: find . ! -name . -prune -type f List all symbolic link: find . ! -name . -prune -type l List all executable: find . ! -name . -prune -type f -perm +111 You can read POSIX find documentation for more advance options.


2

You can use the file test operators documented in man test. For example, to list symbolic links: for i in *;do if [ -L "$i" ] ;then printf -- "%s\n" "$i";fi;done


1

I'm going to assume you're using ls --color=auto, which tells ls to use color in 'automatic' mode. 'Automatic' mode tells less to see if STDOUT is a terminal, and if so, use color, otherwise don't use color. When you pipe ls into less, STDOUT is not a terminal, it's connected to STDIN of less, which is a normal pipe. The solution, use ls --color or ls ...


1

A command like ls -d *@ lists files whose name ends with @. The @ character is part of the pattern that the file name must match. When ls -F displays a character after a file name, that character is not part of the file name, it's an extra indication added by ls (that's the point of the -F option). ls doesn't have an option to select which types of files to ...


1

While Michael Homer already wrote what happened, here's why it happened (given your comment on his answer I think you already know, but others coming across this question might not). The command you issued was ls -al /usr/lib/*valgrind* The stars are interpreted by the shell even before ls is executed, by replacing it with a list of filenames matching ...


1

Since you have "Permission denied" on a directory, it is likely that the directory does not have execute permissions. Similarly, to traverse a directory tree to get at a file, you would need execute permissions on each directory in between the root and the file (hence the same error for the other command). Try setting the execute permissions on the ...


1

From the GNU manpage -t sort by modification time, newest first -c with -lt: sort by, and show, ctime (time of last modification of file status information) with -l: show ctime and sort by name otherwise: sort by ctime, newest first When -c is used with -lt, it will show and sort by file ctimes (instead of modification ...


1

You can use $LS_COLORS to do this. If your version of ls supports specifying the colors using that variable, you can define output per file type. It's builtin behavior and very configurable. So I created some files to demo this like: for f in 9 8 7 6 5 4 3 2 1 do touch "${f}file" && ln -s ./"${f}file" ./"${f}filelink" done So now I'll do: ...


1

Let us try and understand from basic. mkdir test touch file mkdir test1 mkdir test2 The ? searches for one, and only one, character. Now, when we issue the command ls tes? the output would be, file. It worked because we created a file inside the directory. From man page of ls, NAME ls - list directory contents The directory test has the file ...


1

A timestamp in the future is a common consequence of using NFS when the client and the server have different times. To avoid this, make sure that your NFS client and your NFS server are synchronized to the same time source over NTP. In a small network, it's fairly common to have a central server that serves NFS, NTP and often other things. That server may be ...


1

Trying to run ls on a directory with over 30-40k files will just have ls run out of memory and die. This is because it's trying to run stat() on all the files before outputting them. There is no strict limitation in the source though.



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