Re: quick howto-command questions?
On Wed, Mar 21, 2001 at 07:10:03PM -0800, Alexander Poquet wrote: ls -a | grep .c$ This is silly, of course, but if you want to be rigorous about it you probably should do 'ls -a | grep \\.c$' because grep (unlike the shell) uses proper regex syntax -- in which '.' is a special character (match any char). Thus 'ls -a | grep .c$ would list files such as 'fooc', so escaping the . is necessary. Two backslashes are required to get through the shell escaping. Apropos, I have a question: frequently I am in a directory (such as /dev, for example) which has more stuff in it than I can see in one screenful. Normally I pipe it through less, but am bothered by the 'one file per line'-isms that ls spits out in this case. I understand the necessity of this behaviour, but I was wondering, is there some option which forces columnated output regardless of the presence of a filter? -C is documented as column-formatting, but it is ignored in a pipe. ls |column -c80 |less will pipe ls thru column, make it 80 wide, and then through less. In a related question, can one force sort by rows instead of by columns, ie, a b c\nd e f instead of a c e\nb d f? I say related because when viewing copious output through a pager, it would be useful to have sort by rows instead of by columns, which is the default behaviour. easy, simply add the -x flag to column, it ls |column -x -c80 |less -- Jim Richardson Anarchist, pagan and proud of it WWW.eskimo.com/~warlock Linux, because life's too short for a buggy OS.
Re: quick howto-command questions?
On Wed, Mar 21, 2001 at 07:10:03PM -0800, Alexander Poquet wrote: ... Apropos, I have a question: frequently I am in a directory (such as /dev, for example) which has more stuff in it than I can see in one screenful. Normally I pipe it through less, but am bothered by the 'one file per line'-isms that ls spits out in this case. I understand the necessity of this behaviour, but I was wondering, is there some option which forces columnated output regardless of the presence of a filter? -C is documented as column-formatting, but it is ignored in a pipe. Strange, here it works as advertised. What does type ls show? Is it a genuine ls or some build-in degenerate from your shell? Here I get: $ type ls ls is hashed (/bin/ls) $ ls --version ls (GNU fileutils) 4.0l $ dir /usr/bin | head -n 2 822-dategrepmail.DP popauth GET grodvipopclient $ ls -C /usr/bin | head -n 2 822-dategrepmail.DP popauth GET grodvipopclient $ ls --format=vertical /usr/bin | head -n 2 822-dategrepmail.DP popauth GET grodvipopclient $ ls --format=horizontal /usr/bin | head -n 2 822-date GET HEAD Mail MakeTeXPK POST In a related question, can one force sort by rows instead of by columns, ie, a b c\nd e f instead of a c e\nb d f? I say related because when viewing copious output through a pager, it would be useful to have sort by rows instead of by columns, which is the default behaviour. $ ls --format=horizontal -- groetjes, carel
Re: quick howto-command questions?
Try something like this: /bin/ls --color -w $COLUMNS -F -C | less -r or: /bin/dir --color -w $COLUMNS -F | less -r [EMAIL PROTECTED] (Alexander Poquet) writes: Apropos, I have a question: frequently I am in a directory (such as /dev, for example) which has more stuff in it than I can see in one screenful. Normally I pipe it through less, but am bothered by the 'one file per line'-isms that ls spits out in this case. I understand the necessity of this behaviour, but I was wondering, is there some option which forces columnated output regardless of the presence of a filter? -C is documented as column-formatting, but it is ignored in a pipe. -- * For God so loved the world that He gave his only begotten Son, * * that whoever believes in Him should not perish...John 3:16 *
Re: quick howto-command questions?
Hello again tia, Sorry if I sounded a little short-tempered in my last reply. It is a little mind boggling. I did a touch .x.c and the following is the result... P3V4X:/usr/local/Temp/other# touch .x.c P3V4X:/usr/local/Temp/other# ls *.c one.c two.c P3V4X:/usr/local/Temp/other# ls .*c .c .x.c As you can see, the .x.c file displayed in the 'ls' output for me... hmmm. Perplexed, Jimmy Richards On 21 Mar 2001 08:26:07 +, john smith wrote: Hi, mind boggling...;) try touch .x.c instead of just .c .x.c does not show with the rest... any ideas? Hello, Well, I don't know what you're problem is. Just to make sure I was doing this right just for you... I went into a directory that was empty. I then did this touch one.c two.c .c jim This is the results. P3V4X:/usr/local/Temp/other# ls *.c .*c .c one.c two.c P3V4X:/usr/local/Temp/other# ls jim one.c two.c P3V4X:/usr/local/Temp/other# ls -a . .. .c jim one.c two.c Jimmy Richards On 21 Mar 2001 05:08:15 +, john smith wrote: Hi Jimmy, ls *.c.*c gives me no such file or directory... ls *.c .*c That's it, Jimmy Richards On 21 Mar 2001 04:19:07 +, john smith wrote: hi, Let's say I have 3 files namely; one.c, two.c and a hidden .c file (.hid.c). now I want to list them... the command ls -al *.c shows only the two files and it doesn't show the third one... any ideas? tia
Re: quick howto-command questions?
On Wed, Mar 21, 2001 at 04:19:07AM -, john smith wrote: hi, Let's say I have 3 files namely; one.c, two.c and a hidden .c file (.hid.c). now I want to list them... the command ls -al *.c shows only the two files and it doesn't show the third one... any ideas? the command shell (bash, tcsh ...) expands GLOBs such as * or *.c or *this* to include anything in the directory that does not start with DOT. to get the 'hidden' dotfiles you gotta specify the leading dot yourself, as in .??* or .bash* or .log* or .*rc ... so, to see all *.c files that don't start with DOT: ls *.c echo *.c to see all hidden .*.c files, ls .*.c echo .*.c to seem them all-at-once, ls *.c .*.c - sorted lexically echo *.c .*.c - each glob expansion is sorted -- It is always hazardous to ask Why? in science, but it is often interesting to do so just the same. -- Isaac Asimov, 'The Genetic Code' [EMAIL PROTECTED] http://newbieDoc.sourceforge.net/ -- we need your brain! http://www.dontUthink.com/ -- your brain needs us!
Re: quick howto-command questions?
On Wed, Mar 21, 2001 at 04:19:07AM -, john smith wrote: hi, Let's say I have 3 files namely; one.c, two.c and a hidden .c file (.hid.c). now I want to list them... the command ls -al *.c shows only the two files and it doesn't show the third one... any ideas? Quite right ... ls -a | grep .c$ (or variations e.g. ls -al | grep .c$) does what you want. Reason is that * doesn't match . Bob -- If we were meant to fly, we wouldn't keep losing our luggage.
Re: quick howto-command questions?
ls -a | grep .c$ This is silly, of course, but if you want to be rigorous about it you probably should do 'ls -a | grep \\.c$' because grep (unlike the shell) uses proper regex syntax -- in which '.' is a special character (match any char). Thus 'ls -a | grep .c$ would list files such as 'fooc', so escaping the . is necessary. Two backslashes are required to get through the shell escaping. Apropos, I have a question: frequently I am in a directory (such as /dev, for example) which has more stuff in it than I can see in one screenful. Normally I pipe it through less, but am bothered by the 'one file per line'-isms that ls spits out in this case. I understand the necessity of this behaviour, but I was wondering, is there some option which forces columnated output regardless of the presence of a filter? -C is documented as column-formatting, but it is ignored in a pipe. In a related question, can one force sort by rows instead of by columns, ie, a b c\nd e f instead of a c e\nb d f? I say related because when viewing copious output through a pager, it would be useful to have sort by rows instead of by columns, which is the default behaviour. -- Alexander Poquet| We leave the obvious generalizations to the [EMAIL PROTECTED]| reader. -- Israel Herstein Use of PGP preferable in reply | Use Linux! pgpjLChwx9ZYK.pgp Description: PGP signature
Re: quick howto-command questions?
Hi John, I think i know some of these 1) ls -a filecount wc -l filecount 2) find /your_dir -perm 0755 -print exec_count wc -l exec_count (i think this'll work.. I didn't try it. man find for more info) 3) ls *.tar.gz tar.gz_count wc -l tar.gz_count 4)ls *.c | sort '|' is know as the 'pipe symbol'. in case you didn't alreay know. Hope that helps! Jimmy Richards On 20 Mar 2001 09:12:41 +, john smith wrote: Hi, Some quick questions; 1. How can I find out the total number of files (also hidden) in the current directory? 2. How can I find out the total number of executable files (also hidden) in the current directory? 3. how to find the total number of files of a given an extension? (ex.*.tar.gz) 4.how to list files alphabetically that end in *.c? please don't forget to CC me. TIA, JOHN _ Get your FREE download of MSN Explorer at http://explorer.msn.com -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: quick howto-command questions?
On Tue, Mar 20, 2001 at 03:21:22AM -0700, Jimmy Richards wrote: Hi John, I think i know some of these 1) ls -a filecount wc -l filecount or ls -a | wc -l 2) find /your_dir -perm 0755 -print exec_count wc -l exec_count (i think this'll work.. I didn't try it. man find for more info) more reliable would be: find /your_dir -perm +0111 -print | wc -l this will find any file with any execute bit set, your example will not catch files which are mode 750, 700, 500, 550, 555, etc etc. 3) ls *.tar.gz tar.gz_count wc -l tar.gz_count ls *.tar.gz | wc -l -- Ethan Benson http://www.alaska.net/~erbenson/ pgpBZG0klBERJ.pgp Description: PGP signature
Re: quick howto-command questions?
Jimmy Richards [EMAIL PROTECTED] wrote: 4)ls *.c | sort 'ls' originally stood for List and Sort, as I remember - at any rate, it already sorts. Its default output format isn't one on which 'sort' would be particularly useful anyway. -- Colin Watson [EMAIL PROTECTED]
Re: quick howto-command questions?
Hi Ethan, Ahh-ha. Thank You for the info. Jim Richards On 20 Mar 2001 01:38:56 -0900, Ethan Benson wrote: On Tue, Mar 20, 2001 at 03:21:22AM -0700, Jimmy Richards wrote: Hi John, I think i know some of these 1) ls -a filecount wc -l filecount or ls -a | wc -l 2) find /your_dir -perm 0755 -print exec_count wc -l exec_count (i think this'll work.. I didn't try it. man find for more info) more reliable would be: find /your_dir -perm +0111 -print | wc -l this will find any file with any execute bit set, your example will not catch files which are mode 750, 700, 500, 550, 555, etc etc. 3) ls *.tar.gz tar.gz_count wc -l tar.gz_count ls *.tar.gz | wc -l -- Ethan Benson http://www.alaska.net/~erbenson/
Re: quick howto-command questions?
Hello Colin, Ok, Thanks for the info. I think I have been piping stuff through grep helping people on IRC so much lately I forgot that yeah, 'ls' output is already sorted! Jim Richards On 20 Mar 2001 11:06:22 +, Colin Watson wrote: Jimmy Richards [EMAIL PROTECTED] wrote: 4)ls *.c | sort 'ls' originally stood for List and Sort, as I remember - at any rate, it already sorts. Its default output format isn't one on which 'sort' would be particularly useful anyway. -- Colin Watson [EMAIL PROTECTED] -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: quick howto-command questions?
To quote john smith [EMAIL PROTECTED], # 1. How can I find out the total number of files (also hidden) in the current # directory? # # 2. How can I find out the total number of executable files (also hidden) in # the current directory? # # 3. how to find the total number of files of a given an extension? # (ex.*.tar.gz) # # 4.how to list files alphabetically that end in *.c? You can use 'find' for all of those. 'man find' :) David Barclay Harris, Clan Barclay Aut agere, aut mori. (Either action, or death.)
RE: quick howto-command questions?
If you're just interested in the current directory for #1, 3 and 4, they are just variations of: ls -la | wc -l or ls -la *.c If you want to look down a subdirectory tree use: find . -name \*.c -print | wc -l -mk -Original Message- From: David B. Harris [mailto:[EMAIL PROTECTED] Sent: Tuesday, March 20, 2001 6:38 AM To: john smith Cc: debian-user@lists.debian.org Subject: Re: quick howto-command questions? To quote john smith [EMAIL PROTECTED], # 1. How can I find out the total number of files (also hidden) in the current # directory? # # 2. How can I find out the total number of executable files (also hidden) in # the current directory? # # 3. how to find the total number of files of a given an extension? # (ex.*.tar.gz) # # 4.how to list files alphabetically that end in *.c? You can use 'find' for all of those. 'man find' :) David Barclay Harris, Clan Barclay Aut agere, aut mori. (Either action, or death.) -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Re: quick howto-command questions?
On Tue, Mar 20, 2001 at 09:12:41AM -, john smith wrote: Hi, Some quick questions; 1. How can I find out the total number of files (also hidden) in the current directory? ls -a | wc -l 2. How can I find out the total number of executable files (also hidden) in the current directory? Executable by whom? 3. how to find the total number of files of a given an extension? (ex.*.tar.gz) ls *.tar.gz | wc -l 4.how to list files alphabetically that end in *.c? ls *.c please don't forget to CC me. TIA, JOHN _ Get your FREE download of MSN Explorer at http://explorer.msn.com Bob -- Why is the alphabet in that order? Is it because of that song? -- Steven Wright
Re: quick howto-command questions?
On Tue, Mar 20, 2001 at 09:12:41AM -, john smith wrote: 1. How can I find out the total number of files (also hidden) in the current directory? #!/path/to/perl my $dir = shift || '.'; opendir DIR,$dir; my @f = grep( -f $_, # files only, no dirs or other stuff readdir DIR); closedir DIR; print scalar @f; 2. How can I find out the total number of executable files (also hidden) in the current directory? #!/path/to/perl my $dir = shift || '.'; opendir DIR,$dir; my @f = grep( -x $_, # executable by current UID readdir DIR); closedir DIR; print scalar @f; 3. how to find the total number of files of a given an extension? (ex.*.tar.gz) ls *.some.ext | wc -l 4.how to list files alphabetically that end in *.c? ls *.c (ls defaults to lexical/alphabetic sorting; if yours doesn't, you either have a script that's running in place of the normal /bin/ls, or you have an alias that includes a 'sort by something else' command line option.) -- It is always hazardous to ask Why? in science, but it is often interesting to do so just the same. -- Isaac Asimov, 'The Genetic Code' [EMAIL PROTECTED] http://newbieDoc.sourceforge.net/ -- we need your brain! http://www.dontUthink.com/ -- your brain needs us!
Re: quick howto-command questions?
hi, Let's say I have 3 files namely; one.c, two.c and a hidden .c file (.hid.c). now I want to list them... the command ls -al *.c shows only the two files and it doesn't show the third one... any ideas? tia _ Get your FREE download of MSN Explorer at http://explorer.msn.com
Re: quick howto-command questions?
Hi Tia, ls *.c .*c That's it, Jimmy Richards On 21 Mar 2001 04:19:07 +, john smith wrote: hi, Let's say I have 3 files namely; one.c, two.c and a hidden .c file (.hid.c). now I want to list them... the command ls -al *.c shows only the two files and it doesn't show the third one... any ideas? tia
Re: quick howto-command questions?
Hello, Well, I don't know what you're problem is. Just to make sure I was doing this right just for you... I went into a directory that was empty. I then did this touch one.c two.c .c jim This is the results. P3V4X:/usr/local/Temp/other# ls *.c .*c .c one.c two.c P3V4X:/usr/local/Temp/other# ls jim one.c two.c P3V4X:/usr/local/Temp/other# ls -a . .. .c jim one.c two.c Jimmy Richards On 21 Mar 2001 05:08:15 +, john smith wrote: Hi Jimmy, ls *.c.*c gives me no such file or directory... ls *.c .*c That's it, Jimmy Richards On 21 Mar 2001 04:19:07 +, john smith wrote: hi, Let's say I have 3 files namely; one.c, two.c and a hidden .c file (.hid.c). now I want to list them... the command ls -al *.c shows only the two files and it doesn't show the third one... any ideas? tia _ Get your FREE download of MSN Explorer at http://explorer.msn.com