ls interview questions
Top ls frequently asked interview questions
Possible Duplicate:
ls -la symbolics… what does that last symbol mean?
What does the @
in the below execution of ls -al
mean?
atom:Lib fak$ ls -al
total 1056
drwxr-xr-x 5 fak staff 170 Dec 24 13:19 .
drwxr-xr-x 6 fak staff 204 Dec 24 13:15 ..
-rwxr-xr-x@ 1 fak staff 121393 Oct 3 14:05 HtmlAgilityPack.XML
-rwxr-xr-x@ 1 fak staff 101376 Oct 3 14:05 HtmlAgilityPack.dll
-rwxr-xr-x 1 fak staff 315392 Dec 24 13:19 MySql.Data.dll
Source: (StackOverflow)
Something annoying about ls -l
command is it shows only hour and minute for a file(like 08:30). How can I see the second portion(like 08:30:44)?
man 1 ls
and search for 'second' does not give any clue.
Source: (StackOverflow)
I would like to use ls command to first show direcotries and then files. I tried
ls -la | sort -k 1
But I got a wrong order.
Source: (StackOverflow)
When doing an ls
in a directory I get the following output:
drwxr-xr-x@ 12 xonic staff 408 22 Jun 19:00 .
drwxr-xr-x 9 xonic staff 306 22 Jun 19:42 ..
-rwxrwxrwx@ 1 xonic staff 6148 25 Mai 23:04 .DS_Store
-rw-r--r--@ 1 xonic staff 17284 22 Jun 00:20 filmStrip.cpp
-rw-r--r--@ 1 xonic staff 3843 21 Jun 21:20 filmStrip.h
I was wondering what the @
means.
Source: (StackOverflow)
Is there an equivalent to ls -v
in Mac OS X that will do version number sorting?
In Mac OS X, ls -v
does NOT do version number sorting, but the Finder seems to.
Source: (StackOverflow)
Let's say I have a command
ls -Bgclt /somwhere/in/the/past
How do I limit the output to show me only first 2 files? (except for having only 2 files in that directory)
Source: (StackOverflow)
I need to list all of the files my WD sorted alphabetically by the file owner name. Does ls have something for this?
Source: (StackOverflow)
With OS X Yosemite, using the following commands, I get the following:
$ touch .a
$ touch b
$ /bin/ls
b
$ /bin/ls -A
.a b
$ sudo /bin/ls
.a b
It shows hidden files (that have names starting with a dot) when invoked by root and doesn’t show them (as expected) when running as a normal user. This differs from what ls
on Linux (the one coming from coreutils
) does.
Why does ls
behave this way?
Source: (StackOverflow)
I just found this confusing output of the ls
command:
whodare@ubuntu~ $: ls -l /var/spool/cron/
total 12
drwxrwx--T 2 daemon daemon 4096 Oct 29 05:02 atjobs
drwxrwx--T 2 daemon daemon 4096 Sep 15 21:09 atspool
drwx-wx--T 2 root crontab 4096 Dec 24 02:11 crontabs
I know 't' means sticky, but what does 'T' mean?
How can I setup this bit for a directory?
Source: (StackOverflow)
How do I list all files under a directory recursively and sort the output by modification time?
I normally use ls -lhtc
but it doesn't find all files recursively. I am using Linux and Mac.
ls -l
on Mac OS X can give
-rw-r--r-- 1 fsr user 1928 Mar 1 2011 foo.c
-rwx------ 1 fsr user 3509 Feb 25 14:34 bar.c
where the date part isn't consistent or aligned, so a solution have to take this into account.
Partial solution
stat -f "%m%t%Sm %N" ./* | sort -rn | head -3 | cut -f2-
works, but not recursively.
Source: (StackOverflow)
I've done an ls -l
inside a directory, and my files are displaying like this :
james@nevada:~/development/tools/android-sdk-linux_86/tools$ ll
total 9512
drwxr-xr-x 3 james james 4096 2010-05-07 19:48 ./
drwxr-xr-x 6 james james 4096 2010-08-21 20:43 ../
-rwxr-xr-x 1 james james 341773 2010-05-07 19:47 adb*
-rwxr-xr-x 1 james james 3636 2010-05-07 19:47 android*
-rwxr-xr-x 1 james james 2382 2010-05-07 19:47 apkbuilder*
-rwxr-xr-x 1 james james 3265 2010-05-07 19:47 ddms*
-rwxr-xr-x 1 james james 89032 2010-05-07 19:47 dmtracedump*
-rwxr-xr-x 1 james james 1940 2010-05-07 19:47 draw9patch*
-rwxr-xr-x 1 james james 6886136 2010-05-07 19:47 emulator*
-rwxr-xr-x 1 james james 478199 2010-05-07 19:47 etc1tool*
-rwxr-xr-x 1 james james 1987 2010-05-07 19:47 hierarchyviewer*
-rwxr-xr-x 1 james james 23044 2010-05-07 19:47 hprof-conv*
-rwxr-xr-x 1 james james 1939 2010-05-07 19:47 layoutopt*
drwxr-xr-x 4 james james 4096 2010-05-07 19:48 lib/
-rwxr-xr-x 1 james james 16550 2010-05-07 19:47 mksdcard*
-rw-r--r-- 1 james james 205851 2010-05-07 19:48 NOTICE.txt
-rw-r--r-- 1 james james 33 2010-05-07 19:47 source.properties
-rwxr-xr-x 1 james james 1447936 2010-05-07 19:47 sqlite3*
-rwxr-xr-x 1 james james 3044 2010-05-07 19:47 traceview*
-rwxr-xr-x 1 james james 187965 2010-05-07 19:47 zipalign*
What does that asterisk mean?
I'm also unable to run a particular file, as follows :
james@nevada:~/development/tools/android-sdk-linux_86/tools$ ./emulator
bash: ./emulator: No such file or directory
EDIT : I'm trying to get Eclipse to use emulator
, but it keeps complaining the files does not exist, yet it is here?
Source: (StackOverflow)
When I ls
my Desktop from terminal (by using ls ~/Desktop
), I see a file named Icon?
. As far as I can tell, it's empty (nano Icon?
shows nothing). It doesn't show up on my actual Desktop, and open Icon?
shows the Finder alert
This item is used by Mac OS X and can't be opened
Here is the output from mdls Icon?
:
kMDItemContentType = ""
kMDItemFSContentChangeDate = 2009-09-23 13:32:52 -0600
kMDItemFSCreationDate = 2009-09-20 07:27:46 -0600
kMDItemFSCreatorCode = "MACS"
kMDItemFSFinderFlags = 16384
kMDItemFSHasCustomIcon = 0
kMDItemFSInvisible = 1
kMDItemFSIsExtensionHidden = 0
kMDItemFSIsStationery = 0
kMDItemFSLabel = 0
kMDItemFSName = "Icon "
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 20
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 0
kMDItemFSTypeCode = "icon"
Does anyone have an idea as to what this is?
Source: (StackOverflow)
Is there any way to list just the folders in a directory using bash commands? ( as the ls
command lists all the files and folders )
Source: (StackOverflow)