Tag Info

New answers tagged

5

ls -A is the correct answer to your question, but not to the question you linked to (that question was about listing only hidden files and directories).


3

As Vivian suggested, the -t option of ls tells it to sort files by modification time (most recent first, by default; reversed if you add -r).  This is most commonly used (at least in my experience) to sort the files in a directory, but it can also be applied to a list of files on the command line.  And wildcards (“globs”) produce a list of files on the ...


1

This does almost exactly what you want, except it leaves off the trailing / on the directory names. find . -maxdepth 2 -name file1.php -printf '%T@ %h (last modified %Td/%Tm/%TY %Tk:%TM)\n' \ | sort -k 1n | sed 's/^[^ ]* .\///' Credit where credit is due. This is adapted from shlck's answer here. Edit: All of my %A should have been %T


0

Yes it is quite possible. This will give you files which are modified in last 60 minutes: $ find /domain -type f -mmin -60 or this will give you files which are sorted by modify time. $ find /domain -type f -printf '%TY-%Tm-%Td %TT %p\n' | sort -r Edit #1 If you have file extensions like you said '.php', add this: -name '*.php' And I found this ...


2

Colors The coloring is controlled by the DIR_COLORS* files that reside under `/etc. For example on Fedora 19 I have the following 3 files: $ ls -l /etc/DIR_COLORS* -rw-r--r--. 1 root root 5004 Jan 20 2014 /etc/DIR_COLORS -rw-r--r--. 1 root root 5682 Jan 20 2014 /etc/DIR_COLORS.256color -rw-r--r--. 1 root root 4646 Jan 20 2014 ...


-1

I assume this is done in bash. To keep iterating with files with spaces you need to set IFS variable (see bash man). IFS=\n And iterating with following command will list dot files as well. for file in $(ls -A); do echo $file; done


3

You just need to create a list of glob matching files, separated by space: for file in .* *; do echo "$file"; done Edit The above one can rewrite in different form using brace expansion for file in {.*,*}; do echo "$file"; done or even shorter for file in {.,}*; do echo "$file"; done Adding path for selected files: for file in /path/{.,}*; ...


1

If you use the find command you can omit the files that end in the extension .gz like so: $ ls -l total 0 -rw-rw-r--. 1 saml saml 0 Oct 15 22:42 FAIL -rw-rw-r--. 1 saml saml 0 Oct 15 22:42 FAIL.gz $ find . -name "*FAIL*" ! -name "*.gz" ./FAIL You can also filter ls output like so: $ ls *FAIL* | grep -v '.gz' FAIL But it's generally advisable to not ...


1

You can test against the presence of a regex for those extensions: for file in *FAIL*; do [[ ! $file =~ .(bz2|gz) ]] && printf "%s\n" "$file"; done Insert obligatory warning about not parsing ls...


0

Most simply use export LC_ALL=C,make the script with ls,sort,etc and then return to you favourite LC,in my case UTF8.


4

Check your environment variable LC_COLLATE. The easiest thing will be to use the command locales. If you want, you can set it to a different value. For example, you can do (assuming bash) export LC_COLLATE="C" and that should fix your issue.


1

Every directory has at least two references: one from its parent directory (the Volumes entry in /), and one from its own . entry. If there are subdirectories, each has a .. entry that refers back to the parent, and those also contribute toward the parent's link count. So your /Volumes directory's link count of 9 consists of one from /, plus one from ...


0

. represents the current directory, where as .. represents the parent directory. For example, currently I am in demo directory $cd demo/dir1 $pwd /home/guru/demo/dir1 <- my current directory $cd . $pwd /home/guru/demo/dir1 <- cd again to my current directory cd .. $pwd /home/guru/demo <- cd to parent directory


2

They were probably pressing tab twice to get filename completion. What exactly you are shown depends a bit on the shell: zsh, for example, can be configured to show you file date and size as well, and it is clever enough to only show you directories since you can't cd into a file anyway. Example of bash output: $ cd (tabtab) dira/ dirb/ file.txt ...


3

It's the programmable completion feature of the shell. You can simply press the TAB key twice to gain this behavior. Imagine you type cd Downkoads/St and then press the TAB key. St will be completed to Stuff if it is the only folder starting with St. If there are other folders starting with St in there, you will get a list of them by pressing TAB twice. For ...


5

This usually indicates that the filesystem, specifically the meta data pertaining to that particular file has become corrupt. You could try performing a fsck on the disk, but I'd suggest doing this with the filesystem unmounted. Using /forcefsck You can usually schedule a check at the next reboot like so: $ sudo touch /forcefsck $ sudo reboot Using ...


0

ls has two time display formats: For timestamps from the past 6 months: month, day, hour, minute. For other timestamps (in the future, or from more than 6 months ago): year, month, day. The intent is to gain horizontal space and not overwhelm the user with information. Showing “from this year” is more obvious than showing the current year and letting the ...


0

Problem solved. The problem is that if the date is in the future, it will display the year instead of the hour. Here's a simple example: touch file and l gives -rw-r--r-- 1 ABCD DEF 0 sept. 29 12:01 file whic is normal. No try to change the date to be 15 seconds in the future : touch --date "+15 seconds" file and immediately ls -l -rw-r--r-- 1 ABCD DEF ...



Top 50 recent answers are included