This is a discussion on making the ls command my bitch within the Slackware Linux Support forums, part of the Unix Operating Systems category; --> On Thu, 15 Apr 2004 07:51:38 -0000, Scott Eberl <scott@airea420.com> wrote: >I have 3 questions and hopefully at least ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| On Thu, 15 Apr 2004 07:51:38 -0000, Scott Eberl <scott@airea420.com> wrote: >I have 3 questions and hopefully at least 1 of them can be answered. > >1.) Does the ls command have a switch to only list hidden files? ls -la | grep "^\." > >2.) Is it possible to only list directories? ls -la | grep "^d" (will give you directories that start with "." as well, remove the "a" option if you don't want those) You could alias the above commands. > >3.) How do I put vim into insert mode automagicly when it's opened by > slrn to post? > >I know question number 3 is way out there but I figure enough of us in >here use slrn and surely somebody else was annoyed by this who is >smarter then me and figured out how to do it. Sorry, no idea. Scott McMillan |
| |||
| On 2004-04-15, Kenneth <Kenneth@pickone.anyone> wrote: > > That's not a hidden file, it's just a file that begins with a "." > > I've never heard of hidden Linux files. Nevertheless, that definition is commonly found throughout linux literature and the web. A typical linux google link: http://www.abriasoft.com/linuxdemo/c03/03-19.htm nb |
| |||
| Scott McMillan wrote: >>1.) Does the ls command have a switch to only list hidden files? > > ls -la | grep "^\." have you actually tried this? ;-P with a long listing, the filenames are not at the beginning of the line: joost@teuctli:~ $ ls -la | grep "^\." joost@teuctli:~ $ which doesn't mean i don't have dot-files in my home dir. 'ls -lad .*' is really the way to do it. (and it also keeps the colours! ;-) -- Joost Kremers joostkremers@yahoo.com Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9) |
| |||
| Alan Hicks wrote: > > In alt.os.linux.slackware, Ivan dared to utter, >> ls -a | grep '^\.' > > UUOG (Useless Use Of Grep). Unuseful Use Of Grep, i would say... -- Joost Kremers joostkremers@yahoo.com Selbst in die Unterwelt dringt durch Spalten Licht EN:SiS(9) |
| |||
| -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Joost Kremers <joostkremers@yahoo.com> wrote: >>>1.) Does the ls command have a switch to only list hidden files? > 'ls -lad .*' is really the way to do it. (and it also keeps the > colours! ;-) An extension of the above: To avoid listing "." and ".." , execute ls -ad .??* To list only "hidden" files: ls -ad .??* | grep -v /$ To list only "hidden" directories: ls -ad .??* | grep /$ To list only directories: ls | grep /$ NOTE: The last three will only work if / indicators are appended to directories via the -F option (which is aliased to "ls" in Slackware). If this option isn't set (execute "alias" to check), use -Fad as options. - -- George Georgakis geegATtripleg_net_au http://www.tripleg.net.au/ SlackBuild Central - http://slackpack.tripleg.net.au/ -----BEGIN PGP SIGNATURE----- Version: PGPfreeware 6.5.8 for non-commercial use <http://www.pgp.com> iQA/AwUBQH4E8Ulp3nJf7PixEQK6nQCg7/7nfxDkbFm2HVwMJZqBw7D5KHEAnjEH +ZiLPC7YgUH+m6FVgC2ig7/r =6Qs+ -----END PGP SIGNATURE----- |
| |||
| On 15 Apr 2004 13:17:42 GMT, Joost Kremers <joostkremers@yahoo.com> wrote: >Scott McMillan wrote: >>>1.) Does the ls command have a switch to only list hidden files? >> >> ls -la | grep "^\." > >have you actually tried this? ;-P with a long listing, the filenames are >not at the beginning of the line: > >joost@teuctli:~ $ ls -la | grep "^\." >joost@teuctli:~ $ > >which doesn't mean i don't have dot-files in my home dir. 'ls -lad .*' is >really the way to do it. (and it also keeps the colours! ;-) Right you are, my apologies. I must have been on a 'grep' kick thinking about #2. I will be sure to ingest more caffeine before responding in the future ;-) Scott McMillan |
| |||
| George Georgakis <geeg@tripleg.GO.AWAY.SPAMMERS.net.au> wrote: > >An extension of the above: To avoid listing "." and ".." , execute > > ls -ad .??* That of course misses any files like .xx where there are two valid characters after the dot. Such files likely exist. For portablility, use, /bin/ls -ad .[^.]* On Linux or other system with a GNU ls, /bin/ls -Ad >To list only "hidden" files: > > ls -ad .??* | grep -v /$ That is, /files/ and not /directories/. But use, /bin/ls -ad1F .[^.]* | grep -v /$ >To list only "hidden" directories: > > ls -ad .??* | grep /$ The grep is unnecessary, /bin/ls -ad .[^.]*/ >To list only directories: > > ls | grep /$ /bin/ls */ >NOTE: The last three will only work if / indicators are appended >to directories via the -F option (which is aliased to "ls" in >Slackware). If this option isn't set (execute "alias" to check), >use -Fad as options. That should *never* be relied upon. If it requires the -F option, use it. Likewise, in scripts it is a good idea to use the full path name to call ls and other utilities (hence I've shown them that way in my examples above), just to avoid such aliases and instead be guaranteed that one is invoking a standard command (it also avoids builtin commands though). -- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com |
| |||
| "Scott Eberl" <scott@airea420.com> wrote in message news:slrnc7sflj.1kk.scott@turncoat.airea420.com... > I have 3 questions and hopefully at least 1 of them can be answered. > > 1.) Does the ls command have a switch to only list hidden files? I don't know, but since I'm so freakin lazy, rather than look it up, I tried: $ ls -al | grep " \." Seems to work for me. [0] > 2.) Is it possible to only list directories? Yes, but again, I don't know if it's an ls option, but $ ls -al | grep "^d" seems to do the trick. > 3.) How do I put vim into insert mode automagicly when it's opened by > slrn to post? > > I know question number 3 is way out there but I figure enough of us in > here use slrn and surely somebody else was annoyed by this who is > smarter then me and figured out how to do it. This is a good one! Cheers! Rich [0] rich@thunderbird:~$ ls -al total 38 drwx--x--x 10 rich users 528 Apr 13 19:18 ./ drwxr-xr-x 4 root root 96 Mar 17 15:03 ../ -rw------- 1 rich users 161 Apr 13 19:18 .Xauthority -rw------- 1 rich users 3659 Apr 14 18:58 .bash_history drwxr-xr-x 3 rich users 104 Mar 19 16:27 .fullcircle/ drwxr-xr-x 2 rich users 48 Mar 19 16:05 .fvwm/ drwxr-xr-x 3 rich users 128 Mar 19 16:27 .mozilla/ -rw-r--r-- 1 rich users 3394 Mar 17 15:03 .screenrc drwx------ 2 rich users 80 Mar 18 12:28 .ssh/ lrwxrwxrwx 1 rich users 21 Mar 24 02:09 H -> /usr/doc/Linux-HOWTOs/ drwxr-xr-x 2 rich users 104 Mar 17 16:06 bootup/ -rw-r--r-- 1 rich users 811 Mar 25 13:40 directions -rw-r--r-- 1 rich users 1932 Mar 27 12:32 grep-problem -rw-r--r-- 1 rich users 82 Mar 23 14:54 minicom.log -rwxr-xr-x 1 rich users 32 Mar 26 15:52 myip* drwxr-xr-x 2 rich users 176 Apr 13 19:22 pithy-quips/ drwxr-xr-x 4 rich users 104 Apr 2 14:18 programs/ drwxr-xr-x 2 rich users 104 Mar 25 08:10 scripts/ -rw-r--r-- 1 rich users 1416 Mar 19 16:03 whereis-ntpdoc rich@thunderbird:~$ ls -al | grep " \." drwx--x--x 10 rich users 528 Apr 13 19:18 ./ drwxr-xr-x 4 root root 96 Mar 17 15:03 ../ -rw------- 1 rich users 161 Apr 13 19:18 .Xauthority -rw------- 1 rich users 3659 Apr 14 18:58 .bash_history drwxr-xr-x 3 rich users 104 Mar 19 16:27 .fullcircle/ drwxr-xr-x 2 rich users 48 Mar 19 16:05 .fvwm/ drwxr-xr-x 3 rich users 128 Mar 19 16:27 .mozilla/ -rw-r--r-- 1 rich users 3394 Mar 17 15:03 .screenrc drwx------ 2 rich users 80 Mar 18 12:28 .ssh/ rich@thunderbird:~$ rich@thunderbird:~$ ls -al | grep "^d" drwx--x--x 10 rich users 560 Apr 15 09:30 ./ drwxr-xr-x 4 root root 96 Mar 17 15:03 ../ drwxr-xr-x 3 rich users 104 Mar 19 16:27 .fullcircle/ drwxr-xr-x 2 rich users 48 Mar 19 16:05 .fvwm/ drwxr-xr-x 3 rich users 128 Mar 19 16:27 .mozilla/ drwx------ 2 rich users 80 Mar 18 12:28 .ssh/ drwxr-xr-x 2 rich users 104 Mar 17 16:06 bootup/ drwxr-xr-x 2 rich users 176 Apr 13 19:22 pithy-quips/ drwxr-xr-x 4 rich users 104 Apr 2 14:18 programs/ drwxr-xr-x 2 rich users 104 Mar 25 08:10 scripts/ rich@thunderbird:~$ |
| ||||
| On 2004-04-15, notbob <notbob@nothome.com> wrote: > On 2004-04-15, Kenneth <Kenneth@pickone.anyone> wrote: >> >> That's not a hidden file, it's just a file that begins with a "." >> >> I've never heard of hidden Linux files. > > Nevertheless, that definition is commonly found throughout linux literature > and the web. A typical linux google link: > > http://www.abriasoft.com/linuxdemo/c03/03-19.htm > > nb Actually, your comment is misleading. A search of google/linux for hidden files will find the tern used, not in relation to Linux, but in relation to the program ls. A number of people referring to hidden files as it relates to a linux program does not make for a history in reference to linux. In fact, the man page for ls makes no ref to hidden files, just dot files. Keep in mind, find, no options, displays dot files, jed directory command displays dot files, lsattr, no option, displays dot files...etc etc. Again, there are no hidden files in Linux. ken |