Tag Info

New answers tagged

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 ...


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


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, ...


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 ...


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 ...


-2

In addition to Arcege's answer, you can also use sudo su <enter password> cd .ssh The sudo command (without another user name) allows you to run commands as the super-user (root), provided you are a sudo-er (your user name is in /etc/sudoers with the correct fields) and know the password to that sudo-enabled user. Warning: Operating as the ...


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 ...


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 ...


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: ...


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 ...


0

You can try dircolors -p >.dircolors It also can solve the problem


0

Nobody mention about -s option(?). From man ls: -s, --size print the allocated size of each file, in blocks .. so if you list with ls -s then you will get number of blocks for each directory and file in current directory. When you summarize it then you will get exactly the same number as in total: you see on top of ls -l. Extra: To get block ...


-2

Try this one: ls | grep -v " -> "


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 ...


-2

Try this command: ls -p | grep -v @


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 ...


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 ...


0

POSIX has this to say about dates in an ls -long listing: The <date and time> field shall contain the appropriate date and timestamp of when the file was last modified. In the POSIX locale, the field shall be the equivalent of the output of the following date command: date "+%b %e %H:%M" ...if the file has been modified in the last six ...


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.


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.


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 ...


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 ...


0

Why not pipe the result of find through sort and then execute ls for each of the lines? find . -type f -ctime -1 | sort | while IFS= read -r filename; do ls -ls "$filename"; done


-1

ls -l $(find /home/setefgge/public_html -type f -ctime -1 | sort)


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! :)


3

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


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 ...



Top 50 recent answers are included