Tag Info

New answers tagged

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


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

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


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


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.


0

You can list a directory containing 8 million files! But not with ls. The trick is to understand getdents(), the low level system call that reads directory entries from disk, and returns a directory entry (dirent) data structure. source: https://www.olark.com/spw/2011/08/you-can-list-a-directory-with-8-million-files-but-not-with-ls/


4

With GNU ls (the -U option to tell ls not to sort the file list is a GNU extension): ls -lUd -- *(/) .*(/) .*(^/) The problem though is that if any of those globs don't match, the command will be cancelled, so you could do: myls() ( setopt cshnullglob ls -lUd -- *(/) .*(/) .*(^/) ) That emulates the csh behaviour whereby globs with no match expand ...



Top 50 recent answers are included